32 lines
536 B
Go
32 lines
536 B
Go
package auth
|
|
|
|
import "time"
|
|
|
|
type Session struct {
|
|
Token string
|
|
UserId int64
|
|
Device string
|
|
Address string
|
|
CreatedAt time.Time
|
|
ExpiresAt time.Time
|
|
}
|
|
|
|
type Invite struct {
|
|
Token string
|
|
Uses int64
|
|
CreatedAt time.Time
|
|
ExpiresAt time.Time
|
|
}
|
|
|
|
func (s *Session) CreatedAtLocal() string {
|
|
return s.CreatedAt.Local().Format("2006-01-02 15:04")
|
|
}
|
|
|
|
func (s *Session) IsValid() bool {
|
|
return time.Now().Before(s.ExpiresAt)
|
|
}
|
|
|
|
func (i *Invite) IsValid() bool {
|
|
return time.Now().Before(i.ExpiresAt) && i.Uses > 0
|
|
}
|