aboutsummaryrefslogtreecommitdiff
path: root/model/session.go
blob: 5ff079b09dd8144b58086fa8adc7d652647703f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package model

import (
	"errors"
)

var (
	ErrSessionNotFound = errors.New("session not found")
)

type Session struct {
	ID             string   `json:"id"`
	UserID         string   `json:"user_id"`
	InstanceDomain string   `json:"instance_domain"`
	AccessToken    string   `json:"access_token"`
	CSRFToken      string   `json:"csrf_token"`
	Settings       Settings `json:"settings"`
}

type SessionRepo interface {
	Add(session Session) (err error)
	Get(sessionID string) (session Session, err error)
	Remove(sessionID string)
}

func (s Session) IsLoggedIn() bool {
	return len(s.AccessToken) > 0
}