session

package
v0.0.0-...-f06a132 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSessionDurationDay = 7 // No. of days login session will last

Variables

This section is empty.

Functions

This section is empty.

Types

type LicenseExpiredError

type LicenseExpiredError struct{}

func (LicenseExpiredError) Error

func (l LicenseExpiredError) Error() string

type Session

type Session struct {
	ID        uint `gorm:"primarykey"`
	UserID    uint
	Token     string
	CreatedAt time.Time
	ExpiresAt time.Time

	User user.User
}

type SessionService

type SessionService struct {
	// contains filtered or unexported fields
}

func InitSessionService

func InitSessionService(userService *user.UserService, db *gorm.DB) *SessionService

func (*SessionService) CreateUserSession

func (a *SessionService) CreateUserSession(ctx context.Context, email string, password string) (*user.User, string, int64, error)

Verifies user email and password, then generates session for user, returning the user object, session token, and time of expiry

func (*SessionService) DeleteSession

func (a *SessionService) DeleteSession(session Session) error

Delete session from cache and DB

func (*SessionService) GetSessionByToken

func (a *SessionService) GetSessionByToken(token string) (*user.User, error)

Retrieves session user from token. If session is expired, deletes session and returns error

type UserNotVerifiedError

type UserNotVerifiedError struct {
}

func (UserNotVerifiedError) Error

func (u UserNotVerifiedError) Error() string

Jump to

Keyboard shortcuts

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