sessionmdl

package
v1.2.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound            = errors.New("user not found")
	ErrSessionNotFound         = errors.New("session not found")
	ErrInvalidSessionInstance  = errors.New("got invalid session instance id")
	ErrSessionValidationFailed = errors.New("session validation failed")
)

Functions

func CheckForSessionAvailability

func CheckForSessionAvailability(userId, sessionFor string) bool

CheckForSessionAvailability checks if the user has active session for provided `sessionFor`. Returns true if session is available.

func Delete

func Delete(userId string)

Delete removes all the sessions associated with the user.

func DeleteSession

func DeleteSession(userId, sessionFor string)

DeleteSession removes a particular session for user, if present.

func Init

func Init(cache cachemdl.Cacher)

Init initializes sessions with provided cache. Subsequent calls will not have any effect after first initialization.

func Set

func Set(userId string, s ...Session)

Set stores the sessions for provided userId. Session is appended to the list. It does not check if the same session exists or not.

func ValidateSessionFromToken

func ValidateSessionFromToken(claims map[string]interface{}) error

ValidateSessionFromToken checks for session id in claims against available sessions. Validate only if a nonempty `sessionId` is present. The claims must contain `userId` field if session is present.

Types

type Session

type Session struct {
	SessionFor string
	SessionId  string
}

func Get

func Get(userId string) ([]Session, error)

Get returns all the available sessions for the user. This may contain expired but not deleted sessions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL