-
Notifications
You must be signed in to change notification settings - Fork 0
/
session.go
36 lines (30 loc) · 833 Bytes
/
session.go
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
29
30
31
32
33
34
35
36
package userland
import (
"github.com/go-errors/errors"
"time"
)
var (
//ErrSessionNotFound represent session not found
ErrSessionNotFound = errors.New("Session not found")
)
//Session is domain entity
type Session struct {
ID string
Token string
IP string
ClientID int
ClientName string
Expiration time.Duration
CreatedAt time.Time
UpdatedAt time.Time
}
//Sessions a collection of Session
type Sessions []Session
//SessionRepository provide an interface to get user sessions
type SessionRepository interface {
Create(userID int, session Session) error
FindAllByUserID(userID int) (Sessions, error)
DeleteExpiredSessions(userID int) error
DeleteBySessionID(userID int, sessionID string) error
DeleteOtherSessions(userID int, sessionID string) (deletedSessionIDs []string, err error)
}