session

package
v1.12.8 Latest Latest
Warning

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

Go to latest
Published: May 7, 2022 License: AGPL-3.0, AGPL-3.0-only Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExpired = errors.New("your session has been expired")
View Source
var ErrKeyConflict = errors.New("conflict key in database")

Functions

This section is empty.

Types

type Manager

type Manager interface {
	Create(ctx context.Context, a domain.Auth) (string, Session, error)
	Get(ctx context.Context, key string) (Session, error)
	Revoke(ctx context.Context, key string) error
	RevokeUser(ctx context.Context, id model.IDType) error
}

func New

func New(c cache.Generic, repo Repo, log *zap.Logger) Manager

type PersistSession

type PersistSession struct {
	CreatedAt time.Time
	ExpiredAt time.Time
	Key       string
	Value     Session
	UserID    model.IDType
}

type Repo

type Repo interface {
	Create(ctx context.Context, key string, userID model.IDType, s Session) error
	Get(ctx context.Context, key string) (PersistSession, error)
	RevokeUser(ctx context.Context, userID model.IDType) (keys []string, err error)
	Revoke(ctx context.Context, key string) error
}

func NewMysqlRepo

func NewMysqlRepo(q *query.Query, logger *zap.Logger) Repo

type Session

type Session struct {
	RegTime   time.Time    `json:"reg_time"`
	UserID    model.IDType `json:"user_id"`
	GroupID   uint8        `json:"group_id"`
	ExpiredAt int64        `json:"expired_at"`
}

Jump to

Keyboard shortcuts

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