2020-12-04 13:10:32 +01:00
|
|
|
package hub
|
2020-10-03 13:50:30 +02:00
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
2020-12-04 11:02:19 +01:00
|
|
|
// Session represents backend api session data.
|
2020-10-03 13:50:30 +02:00
|
|
|
type Session struct {
|
2020-10-04 04:47:54 +02:00
|
|
|
MapKey string
|
2022-11-27 18:00:55 +01:00
|
|
|
Customer string `json:",omitempty"`
|
2020-10-04 04:47:54 +02:00
|
|
|
ExpiresAt string
|
2020-10-03 13:50:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|