session

package
v0.33.15 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: AGPL-3.0, AGPL-3.0-only Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const CookieKey = "chiiNextSessionID"

Variables

View Source
var ErrExpired = errors.New("your session has been expired")

Functions

This section is empty.

Types

type Manager

type Manager interface {
	Create(ctx context.Context, a auth.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.UserID) error
}

func New

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

type Repo

type Repo interface {
	Create(
		ctx context.Context, userID model.UserID, regTime time.Time, keyGen func() string,
	) (key string, s Session, err error)
	Get(ctx context.Context, key string) (Session, error)
	RevokeUser(ctx context.Context, userID model.UserID) (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.UserID `json:"user_id"`
	CreatedAt int64        `json:"created_at"`
	ExpiredAt int64        `json:"expired_at"`
}

Jump to

Keyboard shortcuts

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