account

package
v0.0.0-...-41f935c Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxFreeSignInAttempts  = 3
	MaxSignInThrottleDelay = app.SignInThrottleTTL / 2
)
View Source
const (
	SignInMethodNone      = ""
	SignInMethodPassword  = "account.user.sign_in_method.password"
	SignInMethodMagicLink = "account.user.sign_in_method.magic_link"
	SignInMethodGoogle    = "account.user.sign_in_method.google"
	SignInMethodFacebook  = "account.user.sign_in_method.facebook"
)
View Source
const (
	SignUpMethodNone        = ""
	SignUpMethodSystemSetup = "account.user.sign_up_method.system_setup"
	SignUpMethodWebForm     = "account.user.sign_up_method.web_form"
	SignUpMethodMagicLink   = "account.user.sign_up_method.magic_link"
	SignUpMethodGoogle      = "account.user.sign_up_method.google"
	SignUpMethodFacebook    = "account.user.sign_up_method.facebook"
	SignUpMethodInvite      = "account.user.sign_up_method.invite"
)

Variables

View Source
var (
	ErrNotVerified      = i18n.M("account.user.error.not_verified")
	ErrAlreadyVerified  = i18n.M("account.user.error.already_verified")
	ErrNotActivated     = i18n.M("account.user.error.not_activated")
	ErrAlreadyActivated = i18n.M("account.user.error.already_activated")
	ErrSuspended        = i18n.M("account.user.error.is_suspended")
	ErrInvalidPassword  = i18n.M("account.user.error.invalid_password")
)
View Source
var ErrAuth = errors.New("auth")
View Source
var ErrFacebookSignUpDisabled = errors.New("Facebook sign up disabled")
View Source
var ErrGoogleSignUpDisabled = errors.New("Google sign up disabled")
View Source
var ErrMagicLinkSignUpDisabled = errors.New("magic link sign up disabled")
View Source
var ErrSignInThrottled = errors.New("sign in throttled")

Functions

func TestRepo

func TestRepo(ctx context.Context, t *testing.T, newRepo func() ReadWriter)

Types

type ActivateTOTPGuard

type ActivateTOTPGuard interface {
	CanActivateTOTP(userID int) bool
}

type ActivateTOTPInput

type ActivateTOTPInput struct {
	UserID int
}

type ActivateUserInput

type ActivateUserInput struct {
	UserID int
}

type ActivateUsersGuard

type ActivateUsersGuard interface {
	CanActivateUsers() bool
}

type Activated

type Activated struct {
	Email       string
	System      string
	Method      string
	HasPassword bool
}

type AlreadySignedUp

type AlreadySignedUp struct {
	Email       string
	System      string
	Method      string
	HasPassword bool
}

type ApproveTOTPResetRequestInput

type ApproveTOTPResetRequestInput struct {
	UserID int
}

type ChangePasswordGuard

type ChangePasswordGuard interface {
	CanChangePassword(userID int) bool
}

type ChangePasswordInput

type ChangePasswordInput struct {
	UserID           int
	OldPassword      Password
	NewPassword      Password
	NewPasswordCheck Password
}

type ChangeRolesGuard

type ChangeRolesGuard interface {
	CanChangeRoles(userID int) bool
}

type ChangeRolesInput

type ChangeRolesInput struct {
	UserID  int
	RoleIDs []int
	Grants  []Permission
	Denials []Permission
}

type ChangeTOTPTelGuard

type ChangeTOTPTelGuard interface {
	CanChangeTOTPTel(userID int) bool
}

type ChangeTOTPTelInput

type ChangeTOTPTelInput struct {
	UserID int
	NewTel Tel
}

type ChoosePasswordGuard

type ChoosePasswordGuard interface {
	CanChoosePassword(userID int) bool
}

type ChoosePasswordInput

type ChoosePasswordInput struct {
	UserID           int
	NewPassword      Password
	NewPasswordCheck Password
}

type CreateRoleGuard

type CreateRoleGuard interface {
	CanCreateRoles() bool
}

type CreateRoleInput

type CreateRoleInput struct {
	Name        RoleName
	Description RoleDesc
	Permissions []Permission
}

type DeleteRoleGuard

type DeleteRoleGuard interface {
	CanDeleteRoles() bool
}

type DeleteRoleInput

type DeleteRoleInput struct {
	RoleID int
}

type DenyTOTPResetRequestInput

type DenyTOTPResetRequestInput struct {
	UserID int
}

type DisableTOTPGuard

type DisableTOTPGuard interface {
	CanDisableTOTP(userID int) bool
}

type DisableTOTPInput

type DisableTOTPInput struct {
	UserID   int
	Password Password
}

type Email

type Email string

func NewEmail

func NewEmail(email string) (Email, error)

func (Email) String

func (e Email) String() string

type FacebookSignInBehavior

type FacebookSignInBehavior byte
const (
	FacebookSignInOnly FacebookSignInBehavior = iota
	FacebookAllowSignUp
	FacebookAllowSignUpActivate
)

type GoogleSignInBehavior

type GoogleSignInBehavior byte
const (
	GoogleSignInOnly GoogleSignInBehavior = iota
	GoogleAllowSignUp
	GoogleAllowSignUpActivate
)

type Hasher

type Hasher interface {
	EncodedPasswordHash(password []byte) ([]byte, error)
	CheckPasswordHash(password, encodedHash []byte) (ok, rehash bool, err error)
	CheckDummyPasswordHash() error
}

type InitialUserSignedUp

type InitialUserSignedUp struct {
	Email  string
	System string
	Method string
}

type InviteUserGuard

type InviteUserGuard interface {
	CanInviteUsers() bool
}

type InviteUserInput

type InviteUserInput struct {
	Email Email
}

type Invited

type Invited struct {
	Email  string
	System string
	Method string
}

type MagicLinkSignInBehavior

type MagicLinkSignInBehavior byte
const (
	MagicLinkSignInOnly MagicLinkSignInBehavior = iota
	MagicLinkAllowSignUp
	MagicLinkAllowSignUpActivate
)

type Password

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

func NewPassword

func NewPassword(password string) (zero Password, _ error)

func (Password) Equal

func (p Password) Equal(rhs Password) bool

func (Password) String

func (p Password) String() string

type PasswordChanged

type PasswordChanged struct {
	Email string
}

type PasswordChosen

type PasswordChosen struct {
	Email string
}

type PasswordReset

type PasswordReset struct {
	Email string
}

type Permission

type Permission string

func NewPermission

func NewPermission(name string) (Permission, error)

func (Permission) String

func (n Permission) String() string

type ReadWriter

type ReadWriter interface {
	Reader
	Writer
}

type Reader

type Reader interface {
	FindRoleByID(ctx context.Context, id int) (*Role, error)

	CountUsers(ctx context.Context) (int, error)
	FindUserByID(ctx context.Context, id int) (*User, error)
	FindUserByEmail(ctx context.Context, email string) (*User, error)

	FindSignInAttemptLogByEmail(ctx context.Context, email string) (*SignInAttemptLog, error)
}

type RecoveryCode

type RecoveryCode string

func NewRandomRecoveryCode

func NewRandomRecoveryCode() (RecoveryCode, error)

func NewRecoveryCode

func NewRecoveryCode(code string) (RecoveryCode, error)

func (RecoveryCode) EqualHash

func (c RecoveryCode) EqualHash(rhs []byte) bool

func (RecoveryCode) String

func (c RecoveryCode) String() string

type RecoveryCodesRegenerated

type RecoveryCodesRegenerated struct {
	Email string
}

type RegenerateRecoveryCodesGuard

type RegenerateRecoveryCodesGuard interface {
	CanRegenerateRecoveryCodes(userID int) bool
}

type RegenerateRecoveryCodesInput

type RegenerateRecoveryCodesInput struct {
	UserID int
	TOTP   TOTP
}

type RequestTOTPResetInput

type RequestTOTPResetInput struct {
	Email Email
}

type ResetPasswordGuard

type ResetPasswordGuard interface {
	CanResetPassword(userID int) bool
}

type ResetPasswordInput

type ResetPasswordInput struct {
	UserID           int
	NewPassword      Password
	NewPasswordCheck Password
}

type ResetTOTPGuard

type ResetTOTPGuard interface {
	CanResetTOTP(userID int) bool
}

type ResetTOTPInput

type ResetTOTPInput struct {
	UserID   int
	Password Password
}

type Role

type Role struct {
	aggregate.Root

	ID          int
	Name        string
	Description string
	Permissions []string
}

func NewRole

func NewRole(name RoleName, description RoleDesc, permissions []Permission) *Role

type RoleDesc

type RoleDesc string

func NewRoleDesc

func NewRoleDesc(desc string) (RoleDesc, error)

func (RoleDesc) String

func (d RoleDesc) String() string

type RoleFilter

type RoleFilter struct {
	ID     *int
	UserID *int
	Name   *string
	Search *string

	SortTopID int
	Sorts     []string

	Limit  int
	Offset int
}

type RoleName

type RoleName string

func NewRoleName

func NewRoleName(name string) (RoleName, error)

func (RoleName) String

func (n RoleName) String() string

type RolesChanged

type RolesChanged struct {
	Email string
}

type Service

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

func NewService

func NewService(broker event.Broker, repo ReadWriter, hasher Hasher, system string) (*Service, error)

func (*Service) ActivateTOTP

func (s *Service) ActivateTOTP(ctx context.Context, guard ActivateTOTPGuard, userID int) (*User, error)

func (*Service) ActivateTOTPValidate

func (s *Service) ActivateTOTPValidate(guard ActivateTOTPGuard, userID int) (ActivateTOTPInput, error)

func (*Service) ActivateUser

func (s *Service) ActivateUser(ctx context.Context, guard ActivateUsersGuard, userID int) (*User, error)

func (*Service) ActivateUserValidate

func (s *Service) ActivateUserValidate(guard ActivateUsersGuard, userID int) (ActivateUserInput, error)

func (*Service) ApproveTOTPResetRequest

func (s *Service) ApproveTOTPResetRequest(ctx context.Context, userID int) (*User, error)

func (*Service) ApproveTOTPResetRequestValidate

func (s *Service) ApproveTOTPResetRequestValidate(userID int) (ApproveTOTPResetRequestInput, error)

func (*Service) ChangePassword

func (s *Service) ChangePassword(ctx context.Context, guard ChangePasswordGuard, userID int, oldPassword, newPassword, newPasswordCheck string) (*User, error)

func (*Service) ChangePasswordValidate

func (s *Service) ChangePasswordValidate(guard ChangePasswordGuard, userID int, oldPassword, newPassword, newPasswordCheck string) (ChangePasswordInput, error)

func (*Service) ChangeRoles

func (s *Service) ChangeRoles(ctx context.Context, guard ChangeRolesGuard, userID int, roleIDs []int, grants, denials []string) (*User, error)

func (*Service) ChangeRolesValidate

func (s *Service) ChangeRolesValidate(guard ChangeRolesGuard, userID int, roleIDs []int, grants, denials []string) (ChangeRolesInput, error)

func (*Service) ChangeTOTPTel

func (s *Service) ChangeTOTPTel(ctx context.Context, guard ChangeTOTPTelGuard, userID int, newTel string) (*User, error)

func (*Service) ChangeTOTPTelValidate

func (s *Service) ChangeTOTPTelValidate(guard ChangeTOTPTelGuard, userID int, newTel string) (ChangeTOTPTelInput, error)

func (*Service) CheckSignInThrottle

func (s *Service) CheckSignInThrottle(attempts int, lastAttemptAt time.Time) error

func (*Service) ChoosePassword

func (s *Service) ChoosePassword(ctx context.Context, guard ChoosePasswordGuard, userID int, newPassword, newPasswordCheck string) (*User, error)

func (*Service) ChoosePasswordValidate

func (s *Service) ChoosePasswordValidate(guard ChoosePasswordGuard, userID int, newPassword, newPasswordCheck string) (ChoosePasswordInput, error)

func (*Service) CreateRole

func (s *Service) CreateRole(ctx context.Context, guard CreateRoleGuard, name, description string, permissions []string) (*Role, error)

func (*Service) CreateRoleValidate

func (s *Service) CreateRoleValidate(guard CreateRoleGuard, name, description string, permissions []string) (CreateRoleInput, error)

func (*Service) DeleteRole

func (s *Service) DeleteRole(ctx context.Context, guard DeleteRoleGuard, roleID int) (*Role, error)

func (*Service) DeleteRoleValidate

func (s *Service) DeleteRoleValidate(guard DeleteRoleGuard, roleID int) (DeleteRoleInput, error)

func (*Service) DenyTOTPResetRequest

func (s *Service) DenyTOTPResetRequest(ctx context.Context, userID int) (*User, error)

func (*Service) DenyTOTPResetRequestValidate

func (s *Service) DenyTOTPResetRequestValidate(userID int) (DenyTOTPResetRequestInput, error)

func (*Service) DisableTOTP

func (s *Service) DisableTOTP(ctx context.Context, guard DisableTOTPGuard, userID int, password string) (*User, error)

func (*Service) DisableTOTPValidate

func (s *Service) DisableTOTPValidate(guard DisableTOTPGuard, userID int, password string) (DisableTOTPInput, error)

func (*Service) InviteUser

func (s *Service) InviteUser(ctx context.Context, guard InviteUserGuard, email string) (*User, error)

func (*Service) InviteUserValidate

func (s *Service) InviteUserValidate(guard InviteUserGuard, email string) (InviteUserInput, error)

func (*Service) RegenerateRecoveryCodes

func (s *Service) RegenerateRecoveryCodes(ctx context.Context, guard RegenerateRecoveryCodesGuard, userID int, totp string) (*User, []string, error)

func (*Service) RegenerateRecoveryCodesValidate

func (s *Service) RegenerateRecoveryCodesValidate(guard RegenerateRecoveryCodesGuard, userID int, totp string) (RegenerateRecoveryCodesInput, error)

func (*Service) RequestTOTPReset

func (s *Service) RequestTOTPReset(ctx context.Context, email string) (*User, error)

func (*Service) RequestTOTPResetValidate

func (s *Service) RequestTOTPResetValidate(email string) (RequestTOTPResetInput, error)

func (*Service) ResetPassword

func (s *Service) ResetPassword(ctx context.Context, guard ResetPasswordGuard, userID int, newPassword, newPasswordCheck string) (*User, error)

func (*Service) ResetPasswordValidate

func (s *Service) ResetPasswordValidate(guard ResetPasswordGuard, userID int, newPassword, newPasswordCheck string) (ResetPasswordInput, error)

func (*Service) ResetTOTP

func (s *Service) ResetTOTP(ctx context.Context, guard ResetTOTPGuard, userID int, password string) (*User, error)

func (*Service) ResetTOTPValidate

func (s *Service) ResetTOTPValidate(guard ResetTOTPGuard, userID int, password string) (ResetTOTPInput, error)

func (*Service) SetupTOTP

func (s *Service) SetupTOTP(ctx context.Context, guard SetupTOTPGuard, userID int) (*User, error)

func (*Service) SetupTOTPValidate

func (s *Service) SetupTOTPValidate(guard SetupTOTPGuard, userID int) (SetupTOTPInput, error)

func (*Service) SignInWithFacebook

func (s *Service) SignInWithFacebook(ctx context.Context, email string, behavior FacebookSignInBehavior) (*User, bool, error)

func (*Service) SignInWithFacebookValidate

func (s *Service) SignInWithFacebookValidate(email string) (SignInWithFacebookInput, error)

func (*Service) SignInWithGoogle

func (s *Service) SignInWithGoogle(ctx context.Context, email string, behavior GoogleSignInBehavior) (*User, bool, error)

func (*Service) SignInWithGoogleValidate

func (s *Service) SignInWithGoogleValidate(email string) (SignInWithGoogleInput, error)
func (s *Service) SignInWithMagicLink(ctx context.Context, email string, behavior MagicLinkSignInBehavior) (*User, bool, error)

func (*Service) SignInWithMagicLinkValidate

func (s *Service) SignInWithMagicLinkValidate(email string) (SignInWithMagicLinkInput, error)

func (*Service) SignInWithPassword

func (s *Service) SignInWithPassword(ctx context.Context, email, password string) (*User, error)

func (*Service) SignInWithPasswordValidate

func (s *Service) SignInWithPasswordValidate(email, password string) (SignInWithPasswordInput, error)

func (*Service) SignInWithRecoveryCode

func (s *Service) SignInWithRecoveryCode(ctx context.Context, userID int, recoveryCode string) (*User, error)

func (*Service) SignInWithRecoveryCodeValidate

func (s *Service) SignInWithRecoveryCodeValidate(userID int, recoveryCode string) (SignInWithRecoveryCodeInput, error)

func (*Service) SignInWithTOTP

func (s *Service) SignInWithTOTP(ctx context.Context, userID int, totp string) (*User, error)

func (*Service) SignInWithTOTPValidate

func (s *Service) SignInWithTOTPValidate(userID int, totp string) (SignInWithTOTPInput, error)

func (*Service) SignUp

func (s *Service) SignUp(ctx context.Context, email string) (*User, error)

func (*Service) SignUpInitialUser

func (s *Service) SignUpInitialUser(ctx context.Context, email, password, passwordCheck string, roleIDs []int) (*User, error)

func (*Service) SignUpInitialUserValidate

func (s *Service) SignUpInitialUserValidate(email, password, passwordCheck string, roleIDs []int) (SignUpInitialUserInput, error)

func (*Service) SignUpValidate

func (s *Service) SignUpValidate(email string) (SignUpInput, error)

func (*Service) SuspendUser

func (s *Service) SuspendUser(ctx context.Context, guard SuspendUsersGuard, userID int, suspendedReason string) (*User, error)

func (*Service) SuspendUserValidate

func (s *Service) SuspendUserValidate(guard SuspendUsersGuard, userID int, suspendedReason string) (SuspendUserInput, error)

func (*Service) UnsuspendUser

func (s *Service) UnsuspendUser(ctx context.Context, guard UnsuspendUsersGuard, userID int) (*User, error)

func (*Service) UnsuspendUserValidate

func (s *Service) UnsuspendUserValidate(guard UnsuspendUsersGuard, userID int) (UnsuspendUserInput, error)

func (*Service) UpdateRole

func (s *Service) UpdateRole(ctx context.Context, guard UpdateRoleGuard, roleID int, name, description string, permissions []string) (*Role, error)

func (*Service) UpdateRoleValidate

func (s *Service) UpdateRoleValidate(guard UpdateRoleGuard, roleID int, name, description string, permissions []string) (UpdateRoleInput, error)

func (*Service) VerifyTOTP

func (s *Service) VerifyTOTP(ctx context.Context, guard VerifyTOTPGuard, userID int, totp, totpMethod string) (*User, []string, error)

func (*Service) VerifyTOTPValidate

func (s *Service) VerifyTOTPValidate(guard VerifyTOTPGuard, userID int, totp, totpMethod string) (VerifyTOTPInput, error)

func (*Service) VerifyUser

func (s *Service) VerifyUser(ctx context.Context, email, password, passwordCheck string, behavior VerifyUserBehavior) (*User, error)

func (*Service) VerifyUserValidate

func (s *Service) VerifyUserValidate(email, password, passwordCheck string) (VerifyUserInput, error)

type SetupTOTPGuard

type SetupTOTPGuard interface {
	CanSetupTOTP(userID int) bool
}

type SetupTOTPInput

type SetupTOTPInput struct {
	UserID int
}

type SignInAttemptLog

type SignInAttemptLog struct {
	aggregate.Root

	Email         string
	Attempts      int
	LastAttemptAt time.Time
}

type SignInThrottleError

type SignInThrottleError struct {
	InLast   time.Duration
	Delay    time.Duration
	UnlockAt time.Time
	UnlockIn time.Duration
}

func (SignInThrottleError) Error

func (t SignInThrottleError) Error() string

type SignInWithFacebookInput

type SignInWithFacebookInput struct {
	Email Email
}

type SignInWithGoogleInput

type SignInWithGoogleInput struct {
	Email Email
}

type SignInWithMagicLinkInput

type SignInWithMagicLinkInput struct {
	Email Email
}

type SignInWithPasswordInput

type SignInWithPasswordInput struct {
	Email    Email
	Password Password
}

type SignInWithRecoveryCodeInput

type SignInWithRecoveryCodeInput struct {
	UserID       int
	RecoveryCode RecoveryCode
}

type SignInWithTOTPInput

type SignInWithTOTPInput struct {
	UserID int
	TOTP   TOTP
}

type SignUpInitialUserInput

type SignUpInitialUserInput struct {
	Email         Email
	Password      Password
	PasswordCheck Password
	RoleIDs       []int
}

type SignUpInput

type SignUpInput struct {
	Email Email
}

type SignedIn

type SignedIn struct {
	Email  string
	System string
	Method string
}

type SignedUp

type SignedUp struct {
	Email      string
	System     string
	Method     string
	IsVerified bool
}

type SuspendUserInput

type SuspendUserInput struct {
	UserID          int
	SuspendedReason SuspendedReason
}

type SuspendUsersGuard

type SuspendUsersGuard interface {
	CanSuspendUsers() bool
}

type Suspended

type Suspended struct {
	Email  string
	Reason string
}

type SuspendedReason

type SuspendedReason string

func NewSuspendedReason

func NewSuspendedReason(reason string) (SuspendedReason, error)

func (SuspendedReason) String

func (s SuspendedReason) String() string

type SuspendedReasonChanged

type SuspendedReasonChanged struct {
	Email  string
	Reason string
}

type TOTP

type TOTP string

func NewTOTP

func NewTOTP(totp string) (TOTP, error)

func (TOTP) String

func (t TOTP) String() string

type TOTPDisabled

type TOTPDisabled struct {
	Email string
}

type TOTPKey

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

func NewTOTPKey

func NewTOTPKey(algorithm otp.Algorithm) (zero TOTPKey, _ error)

type TOTPMethod

type TOTPMethod string
const (
	TOTPMethodNone TOTPMethod = ""
	TOTPMethodApp  TOTPMethod = "app"
	TOTPMethodSMS  TOTPMethod = "sms"
)

func NewTOTPMethod

func NewTOTPMethod(method string) (TOTPMethod, error)

func (TOTPMethod) String

func (t TOTPMethod) String() string

type TOTPReset

type TOTPReset struct {
	Email string
}

type TOTPResetRequestApproved

type TOTPResetRequestApproved struct {
	Email string
}

type TOTPResetRequestDenied

type TOTPResetRequestDenied struct {
	Email string
}

type TOTPResetRequested

type TOTPResetRequested struct {
	Email string
}

type TOTPTelChanged

type TOTPTelChanged struct {
	Email  string
	OldTel string
	NewTel string
}

type Tel

type Tel string

func NewTel

func NewTel(tel string) (Tel, error)

func (Tel) String

func (t Tel) String() string

type UnsuspendUserInput

type UnsuspendUserInput struct {
	UserID int
}

type UnsuspendUsersGuard

type UnsuspendUsersGuard interface {
	CanUnsuspendUsers() bool
}

type Unsuspended

type Unsuspended struct {
	Email string
}

type UpdateRoleGuard

type UpdateRoleGuard interface {
	CanUpdateRoles() bool
}

type UpdateRoleInput

type UpdateRoleInput struct {
	RoleID      int
	Name        RoleName
	Description RoleDesc
	Permissions []Permission
}

type User

type User struct {
	aggregate.Root

	ID                      int
	Email                   string
	HashedPassword          []byte
	TOTPMethod              string
	TOTPTel                 string
	TOTPKey                 []byte
	TOTPAlgorithm           string
	TOTPDigits              int
	TOTPPeriod              time.Duration
	TOTPVerifiedAt          time.Time
	TOTPActivatedAt         time.Time
	TOTPResetRequestedAt    time.Time
	TOTPResetApprovedAt     time.Time
	InvitedAt               time.Time
	SignedUpAt              time.Time
	SignedUpSystem          string
	SignedUpMethod          string
	VerifiedAt              time.Time
	ActivatedAt             time.Time
	LastSignInAttemptAt     time.Time
	LastSignInAttemptSystem string
	LastSignInAttemptMethod string
	LastSignedInAt          time.Time
	LastSignedInSystem      string
	LastSignedInMethod      string
	SuspendedAt             time.Time
	SuspendedReason         string
	HashedRecoveryCodes     [][]byte
	Roles                   []*Role
	Grants                  []string
	Denials                 []string
}

func NewUser

func NewUser(email Email) *User

func (*User) Activate

func (u *User) Activate() error

func (*User) ActivateTOTP

func (u *User) ActivateTOTP() error

func (*User) ApproveTOTPResetRequest

func (u *User) ApproveTOTPResetRequest() error

func (*User) ChangePassword

func (u *User) ChangePassword(oldPassword, newPassword Password, hasher Hasher) error

func (*User) ChangeRoles

func (u *User) ChangeRoles(roles []*Role, grants, denials []Permission)

func (*User) ChangeTOTPTel

func (u *User) ChangeTOTPTel(newTel Tel) error

func (*User) ChoosePassword

func (u *User) ChoosePassword(newPassword Password, hasher Hasher) error

func (*User) DenyTOTPResetRequest

func (u *User) DenyTOTPResetRequest() error

func (*User) DisableTOTP

func (u *User) DisableTOTP(password Password, hasher Hasher) error

func (*User) GenerateTOTP

func (u *User) GenerateTOTP() (string, error)

func (*User) HasActivatedTOTP

func (u *User) HasActivatedTOTP() bool

func (*User) HasSetupTOTP

func (u *User) HasSetupTOTP() bool

func (*User) HasSignedIn

func (u *User) HasSignedIn() bool

func (*User) HasVerifiedTOTP

func (u *User) HasVerifiedTOTP() bool

func (*User) Invite

func (u *User) Invite(system string) error

func (*User) IsActivated

func (u *User) IsActivated() bool

func (*User) IsSuspended

func (u *User) IsSuspended() bool

func (*User) IsVerified

func (u *User) IsVerified() bool

func (*User) Permissions

func (u *User) Permissions() []string

func (*User) RegenerateRecoveryCodes

func (u *User) RegenerateRecoveryCodes(totp TOTP) ([]string, error)

func (*User) RequestTOTPReset

func (u *User) RequestTOTPReset() error

func (*User) ResetPassword

func (u *User) ResetPassword(newPassword Password, hasher Hasher) error

func (*User) ResetTOTP

func (u *User) ResetTOTP(password Password, hasher Hasher) error

func (*User) SetupTOTP

func (u *User) SetupTOTP() error

func (*User) SignInWithFacebook

func (u *User) SignInWithFacebook(system string) error

func (*User) SignInWithGoogle

func (u *User) SignInWithGoogle(system string) error
func (u *User) SignInWithMagicLink(system string) error

func (*User) SignInWithPassword

func (u *User) SignInWithPassword(system string, password Password, hasher Hasher) (bool, error)

func (*User) SignInWithRecoveryCode

func (u *User) SignInWithRecoveryCode(system string, code RecoveryCode) error

func (*User) SignInWithTOTP

func (u *User) SignInWithTOTP(system string, totp TOTP) error

func (*User) SignUp

func (u *User) SignUp(system string)

func (*User) SignUpAsInitialUser

func (u *User) SignUpAsInitialUser(system string, roles []*Role, password Password, hasher Hasher) error

func (*User) SignUpWithFacebook

func (u *User) SignUpWithFacebook(system string)

func (*User) SignUpWithGoogle

func (u *User) SignUpWithGoogle(system string)
func (u *User) SignUpWithMagicLink(system string)

func (*User) Suspend

func (u *User) Suspend(reason SuspendedReason)

func (*User) Unsuspend

func (u *User) Unsuspend()

func (*User) Verify

func (u *User) Verify(password Password, hasher Hasher) error

func (*User) VerifyTOTP

func (u *User) VerifyTOTP(totp TOTP, method TOTPMethod) ([]string, error)

type UserFilter

type UserFilter struct {
	ID     *int
	Email  *string
	Search *string
	RoleID *int

	SortTopID int
	Sorts     []string

	Limit  int
	Offset int
}

type Verified

type Verified struct {
	Email string
}

type VerifyTOTPGuard

type VerifyTOTPGuard interface {
	CanVerifyTOTP(userID int) bool
}

type VerifyTOTPInput

type VerifyTOTPInput struct {
	UserID     int
	TOTP       TOTP
	TOTPMethod TOTPMethod
}

type VerifyUserBehavior

type VerifyUserBehavior byte
const (
	VerifyUserOnly VerifyUserBehavior = iota
	VerifyUserActivate
)

type VerifyUserInput

type VerifyUserInput struct {
	Email         Email
	Password      Password
	PasswordCheck Password
}

type Writer

type Writer interface {
	AddRole(ctx context.Context, role *Role) error
	SaveRole(ctx context.Context, role *Role) error
	RemoveRole(ctx context.Context, roleID int) error

	AddUser(ctx context.Context, user *User) error
	SaveUser(ctx context.Context, user *User) error

	SaveSignInAttemptLog(ctx context.Context, log *SignInAttemptLog) error
}

Jump to

Keyboard shortcuts

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