photoprism/internal/hub/session.go

25 lines
481 B
Go
Raw Normal View History

2020-12-04 13:10:32 +01:00
package hub
import "time"
2020-12-04 11:02:19 +01:00
// Session represents backend api session data.
type Session struct {
Tier int
MapKey string
Customer string `json:",omitempty"`
ExpiresAt string
}
// Expired tests if the api session is expired.
func (p *Session) Expired() bool {
if p.ExpiresAt == "" {
return true
} else if date, err := time.Parse("2006-01-02T15:04:05", p.ExpiresAt); err != nil {
return true
} else if date.Before(time.Now()) {
return true
}
return false
}