Documentation ¶
Index ¶
- type SessionManager
- type SessionRepo
- func (s SessionRepo) FindByTimeAccessed(duration time.Duration) *mgo.Iter
- func (s SessionRepo) FindByToken(token string, profile *model.Token) bool
- func (s SessionRepo) Insert(token, userName string, t time.Time) error
- func (s SessionRepo) Remove(token string) error
- func (s SessionRepo) RemoveAll(duration time.Duration) error
- func (s SessionRepo) Update(token string, t time.Time) error
- type SessionsDB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func InitMockSessions ¶
func InitMockSessions(db SessionsDB, clock utilities.Clock) SessionManager
Mock for tests
func InitSessions ¶
func InitSessions(maxAge int, mongoDB *mgo.Session, dbName, collectionName string, clock utilities.Clock) SessionManager
Initialization of the mongo database, have to set maxage in minute.
func (*SessionManager) DeleteSessionKey ¶
func (sm *SessionManager) DeleteSessionKey(token string) bool
Deletes session token from the database, sets user offline.
func (*SessionManager) GetUser ¶
func (sm *SessionManager) GetUser(token string) string
func (*SessionManager) IsSessionLegit ¶
func (sm *SessionManager) IsSessionLegit(token string) (model.Token, bool)
Checks if Session is in the database, and its still valid, it also refreshes the tokens life and sets the user to online state.
func (*SessionManager) SetSessionKeys ¶
func (sm *SessionManager) SetSessionKeys(ClientIP string, username string) (string, error)
This is the function which generates a token and returns it, The token is automaticaly added to the connected mongoDB and it is added to the local cache.
type SessionRepo ¶
type SessionRepo struct {
// contains filtered or unexported fields
}
func NewSessionRepo ¶
func NewSessionRepo(db *mgo.Collection) SessionRepo
func (SessionRepo) FindByTimeAccessed ¶
func (s SessionRepo) FindByTimeAccessed(duration time.Duration) *mgo.Iter
func (SessionRepo) FindByToken ¶
func (s SessionRepo) FindByToken(token string, profile *model.Token) bool
func (SessionRepo) Remove ¶
func (s SessionRepo) Remove(token string) error
type SessionsDB ¶
Click to show internal directories.
Click to hide internal directories.