Versions in this module Expand all Collapse all v0 v0.1.3 May 17, 2024 v0.1.2 Apr 17, 2024 Changes in this version type SessionManager + Token func() string v0.1.1 Mar 25, 2024 Changes in this version type UserManager + func CreateUserManager(db *quirk.DB, cache cache.Client, id int, email string) UserManager + MustResetPassword func(token ...string) string + ResetPassword func(token ...string) (string, error) v0.1.0 Feb 20, 2024 Changes in this version + const DefaultDuration + const SessionCacheKey + const SessionCookieKey + const TfaCacheKey + const TfaCookieKey + const TfaImageSize + const UserActive + const UserEmail + const UserLastActivity + const UserPassword + const UserRoles + const UserTfa + const UserTfaCodes + const UserTfaSecret + const UserTfaUrl + var ErrorCredentialsMismatch = errors.New("client is not equal with session") + var ErrorInvalidCredentials = errors.New("invalid credentials") + var ErrorInvalidOtp = errors.New("invalid otp") + var ErrorInvalidUser = errors.New("invalid user") + var ErrorMismatchPassword = errors.New("passwords aren't equal") + var ErrorMissingSessionCookie = errors.New("session cookie does not exist") + var ErrorMissingTfaCookie = errors.New("tfa cookie does not exist") + var ErrorMissingUser = errors.New("user doesn't exist") + var ErrorUserAlreadyExists = errors.New("user already exists") + func CreateTable(q *quirk.Quirk) error + func DropTable(q *quirk.Quirk) error + func MustCreateTable(q *quirk.Quirk) + func MustDropTable(q *quirk.Quirk) + type Config struct + Duration time.Duration + Roles map[string]Role + type In struct + Ok bool + Tfa bool + Token string + type Manager interface + CustomUser func(id int, email string) UserManager + In func(email, password string) (In, error) + MustIn func(email, password string) In + MustOut func() + Out func() error + Session func() SessionManager + Tfa func() TfaManager + User func() UserManager + func New(db *quirk.DB, req *http.Request, res http.ResponseWriter, cookie cookie.Cookie, ...) Manager + type Role struct + Super bool + type Session struct + Email string + Id int + Ip string + Roles []string + Super bool + UserAgent string + type SessionManager interface + Destroy func() error + Exists func() (bool, error) + Get func() (Session, error) + MustDestroy func() + MustExists func() bool + MustGet func() Session + MustNew func(user User) string + MustRenew func() + New func(user User) (string, error) + Renew func() error + type TfaManager interface + CreateQrImageBase64 func() (string, error) + Disable func(id ...int) error + Enable func(id ...int) error + GetActive func() (bool, error) + GetPendingUserId func() (int, error) + GetPendingVerification func() (bool, error) + MustCreateQrImageBase64 func() string + MustDisable func(id ...int) + MustEnable func(id ...int) + MustGetActive func() bool + MustGetPendingUserId func() int + MustGetPendingVerification func() bool + MustVerify func(otp string) string + Verify func(otp string) (string, error) + type User struct + Active bool + CreatedAt time.Time + Email string + Id int + LastActivity time.Time + Password string + Roles []string + Tfa bool + TfaCodes sql.Null[string] + TfaSecret sql.Null[string] + TfaUrl sql.Null[string] + UpdatedAt time.Time + type UserManager interface + Create func(r User) (int, error) + Disable func(id ...int) error + Enable func(id ...int) error + ForceUpdatePassword func(newPassword string) error + Get func(id ...int) (User, error) + MustCreate func(r User) int + MustDisable func(id ...int) + MustEnable func(id ...int) + MustForceUpdatePassword func(newPassword string) + MustGet func(id ...int) User + MustUpdate func(r User, columns ...string) + MustUpdatePassword func(actualPassword, newPassword string) + Update func(r User, columns ...string) error + UpdatePassword func(actualPassword, newPassword string) error