2019-12-13 20:08:26 +02:00
|
|
|
package model
|
|
|
|
|
2019-12-17 22:17:25 +02:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
)
|
2019-12-13 20:08:26 +02:00
|
|
|
|
|
|
|
var (
|
|
|
|
ErrSessionNotFound = errors.New("session not found")
|
|
|
|
)
|
|
|
|
|
|
|
|
type Session struct {
|
2019-12-21 13:13:21 +02:00
|
|
|
ID string `json:"id"`
|
|
|
|
InstanceDomain string `json:"instance_domain"`
|
|
|
|
AccessToken string `json:"access_token"`
|
2020-01-25 12:07:06 +02:00
|
|
|
CSRFToken string `json:"csrf_token"`
|
2019-12-21 13:13:21 +02:00
|
|
|
Settings Settings `json:"settings"`
|
2019-12-13 20:08:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type SessionRepository interface {
|
|
|
|
Add(session Session) (err error)
|
|
|
|
Get(sessionID string) (session Session, err error)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s Session) IsLoggedIn() bool {
|
|
|
|
return len(s.AccessToken) > 0
|
|
|
|
}
|