Documentation
¶
Index ¶
Constants ¶
View Source
const ( SessionCookieKey = "X-Session" DefaultDuration = 24 * time.Hour )
View Source
const ( TfaCookieKey = "X-Tfa" TfaImageSize = 200 )
View Source
const ( UserActive = "active" UserRoles = "roles" UserEmail = "email" UserPassword = "password" UserTfa = "tfa" UserTfaSecret = "tfa_secret" UserTfaCodes = "tfa_codes" UserTfaUrl = "tfa_url" UserLastActivity = "last_activity" )
View Source
const ( SessionCacheKey = "session" TfaCacheKey = "tfa" )
Variables ¶
View Source
var ( ErrorMissingSessionCookie = errors.New("session cookie does not exist") ErrorMissingTfaCookie = errors.New("tfa cookie does not exist") ErrorCredentialsMismatch = errors.New("client is not equal with session") ErrorMissingUser = errors.New("user doesn't exist") ErrorMismatchPassword = errors.New("passwords aren't equal") ErrorUserAlreadyExists = errors.New("user already exists") ErrorInvalidUser = errors.New("invalid user") ErrorInvalidOtp = errors.New("invalid otp") ErrorInvalidCredentials = errors.New("invalid credentials") )
Functions ¶
func CreateTable ¶
func MustCreateTable ¶
func MustDropTable ¶
Types ¶
type Manager ¶
type Manager interface {
Session() SessionManager
Tfa() TfaManager
User() UserManager
CustomUser(id int, email string) UserManager
In(email, password string) (In, error)
Out() error
MustIn(email, password string) In
MustOut()
}
type SessionManager ¶
type TfaManager ¶
type TfaManager interface {
GetPendingUserId() (int, error)
GetPendingVerification() (bool, error)
GetActive() (bool, error)
Enable(id ...int) error
Disable(id ...int) error
Verify(otp string) (string, error)
CreateQrImageBase64() (string, error)
MustGetPendingUserId() int
MustGetPendingVerification() bool
MustGetActive() bool
MustEnable(id ...int)
MustDisable(id ...int)
MustVerify(otp string) string
MustCreateQrImageBase64() string
}
type User ¶
type User struct {
Id int `json:"id"`
Active bool `json:"active"`
Roles []string `json:"roles"`
Email string `json:"email"`
Password string `json:"password"`
Tfa bool `json:"tfa"`
TfaSecret sql.Null[string] `json:"tfaSecret"`
TfaCodes sql.Null[string] `json:"tfaCodes"`
TfaUrl sql.Null[string] `json:"tfaUrl"`
LastActivity time.Time `json:"lastActivity"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
type UserManager ¶
type UserManager interface {
Get(id ...int) (User, error)
Create(r User) (int, error)
Update(r User, columns ...string) error
ResetPassword(token ...string) (string, error)
UpdatePassword(actualPassword, newPassword string) error
ForceUpdatePassword(newPassword string) error
Enable(id ...int) error
Disable(id ...int) error
MustGet(id ...int) User
MustCreate(r User) int
MustUpdate(r User, columns ...string)
MustResetPassword(token ...string) string
MustUpdatePassword(actualPassword, newPassword string)
MustForceUpdatePassword(newPassword string)
MustEnable(id ...int)
MustDisable(id ...int)
}
func CreateUserManager ¶ added in v0.1.1
Click to show internal directories.
Click to hide internal directories.