bloat/model/session.go

29 lines
603 B
Go
Raw Permalink Normal View History

2019-12-13 19:08:26 +01:00
package model
import (
"errors"
)
2019-12-13 19:08:26 +01:00
var (
ErrSessionNotFound = errors.New("session not found")
)
type Session struct {
2019-12-21 12:13:21 +01:00
ID string `json:"id"`
2020-02-02 09:30:40 +01:00
UserID string `json:"user_id"`
2019-12-21 12:13:21 +01:00
InstanceDomain string `json:"instance_domain"`
AccessToken string `json:"access_token"`
2020-01-25 11:07:06 +01:00
CSRFToken string `json:"csrf_token"`
2019-12-21 12:13:21 +01:00
Settings Settings `json:"settings"`
2019-12-13 19:08:26 +01:00
}
2020-01-28 18:51:00 +01:00
type SessionRepo interface {
2019-12-13 19:08:26 +01:00
Add(session Session) (err error)
Get(sessionID string) (session Session, err error)
2020-03-04 16:59:59 +01:00
Remove(sessionID string)
2019-12-13 19:08:26 +01:00
}
func (s Session) IsLoggedIn() bool {
return len(s.AccessToken) > 0
}