Documentation
¶
Index ¶
- Constants
- Variables
- func TestRepo(ctx context.Context, t *testing.T, newRepo func() ReadWriter)
- type ActivateTOTPData
- type ActivateTOTPGuard
- type ActivateUserData
- type ActivateUsersGuard
- type Activated
- type AlreadySignedUp
- type ApproveTOTPResetRequestData
- type ChangePasswordData
- type ChangePasswordGuard
- type ChangePasswordInput
- type ChangeRolesData
- type ChangeRolesGuard
- type ChangeRolesInput
- type ChangeTOTPTelData
- type ChangeTOTPTelGuard
- type ChoosePasswordData
- type ChoosePasswordGuard
- type ChoosePasswordInput
- type CreateRoleData
- type CreateRoleGuard
- type CreateRoleInput
- type DeleteRoleData
- type DeleteRoleGuard
- type DenyTOTPResetRequestData
- type DisableTOTPData
- type DisableTOTPGuard
- type Email
- type FacebookSignInBehavior
- type GoogleSignInBehavior
- type Hasher
- type InitialUserSignedUp
- type InviteUserData
- type InviteUserGuard
- type Invited
- type MagicLinkSignInBehavior
- type Password
- type PasswordChanged
- type PasswordChosen
- type PasswordReset
- type Permission
- type ReadWriter
- type Reader
- type RecoveryCode
- type RecoveryCodesRegenerated
- type RegenerateRecoveryCodesData
- type RegenerateRecoveryCodesGuard
- type RequestTOTPResetData
- type ResetPasswordData
- type ResetPasswordGuard
- type ResetPasswordInput
- type ResetTOTPData
- type ResetTOTPGuard
- type Role
- type RoleDesc
- type RoleFilter
- type RoleName
- type RolesChanged
- type Service
- func (s *Service) ActivateTOTP(ctx context.Context, guard ActivateTOTPGuard, userID int) (*User, error)
- func (s *Service) ActivateTOTPValidate(guard ActivateTOTPGuard, userID int) (ActivateTOTPData, error)
- func (s *Service) ActivateUser(ctx context.Context, guard ActivateUsersGuard, userID int) (*User, error)
- func (s *Service) ActivateUserValidate(guard ActivateUsersGuard, userID int) (ActivateUserData, error)
- func (s *Service) ApproveTOTPResetRequest(ctx context.Context, userID int) (*User, error)
- func (s *Service) ApproveTOTPResetRequestValidate(userID int) (ApproveTOTPResetRequestData, error)
- func (s *Service) ChangePassword(ctx context.Context, guard ChangePasswordGuard, input ChangePasswordInput) (*User, error)
- func (s *Service) ChangePasswordValidate(guard ChangePasswordGuard, input ChangePasswordInput) (ChangePasswordData, error)
- func (s *Service) ChangeRoles(ctx context.Context, guard ChangeRolesGuard, input ChangeRolesInput) (*User, error)
- func (s *Service) ChangeRolesValidate(guard ChangeRolesGuard, input ChangeRolesInput) (ChangeRolesData, error)
- func (s *Service) ChangeTOTPTel(ctx context.Context, guard ChangeTOTPTelGuard, userID int, newTel string) (*User, error)
- func (s *Service) ChangeTOTPTelValidate(guard ChangeTOTPTelGuard, userID int, newTel string) (ChangeTOTPTelData, error)
- func (s *Service) CheckSignInThrottle(attempts int, lastAttemptAt time.Time) error
- func (s *Service) ChoosePassword(ctx context.Context, guard ChoosePasswordGuard, input ChoosePasswordInput) (*User, error)
- func (s *Service) ChoosePasswordValidate(guard ChoosePasswordGuard, input ChoosePasswordInput) (ChoosePasswordData, error)
- func (s *Service) CreateRole(ctx context.Context, guard CreateRoleGuard, input CreateRoleInput) (*Role, error)
- func (s *Service) CreateRoleValidate(guard CreateRoleGuard, input CreateRoleInput) (CreateRoleData, error)
- func (s *Service) DeleteRole(ctx context.Context, guard DeleteRoleGuard, roleID int) (*Role, error)
- func (s *Service) DeleteRoleValidate(guard DeleteRoleGuard, roleID int) (DeleteRoleData, error)
- func (s *Service) DenyTOTPResetRequest(ctx context.Context, userID int) (*User, error)
- func (s *Service) DenyTOTPResetRequestValidate(userID int) (DenyTOTPResetRequestData, error)
- func (s *Service) DisableTOTP(ctx context.Context, guard DisableTOTPGuard, userID int, password string) (*User, error)
- func (s *Service) DisableTOTPValidate(guard DisableTOTPGuard, userID int, password string) (DisableTOTPData, error)
- func (s *Service) InviteUser(ctx context.Context, guard InviteUserGuard, email string) (*User, error)
- func (s *Service) InviteUserValidate(guard InviteUserGuard, email string) (InviteUserData, error)
- func (s *Service) RegenerateRecoveryCodes(ctx context.Context, guard RegenerateRecoveryCodesGuard, userID int, ...) (*User, []string, error)
- func (s *Service) RegenerateRecoveryCodesValidate(guard RegenerateRecoveryCodesGuard, userID int, totp string) (RegenerateRecoveryCodesData, error)
- func (s *Service) RequestTOTPReset(ctx context.Context, email string) (*User, error)
- func (s *Service) RequestTOTPResetValidate(email string) (RequestTOTPResetData, error)
- func (s *Service) ResetPassword(ctx context.Context, guard ResetPasswordGuard, input ResetPasswordInput) (*User, error)
- func (s *Service) ResetPasswordValidate(guard ResetPasswordGuard, input ResetPasswordInput) (ResetPasswordData, error)
- func (s *Service) ResetTOTP(ctx context.Context, guard ResetTOTPGuard, userID int, password string) (*User, error)
- func (s *Service) ResetTOTPValidate(guard ResetTOTPGuard, userID int, password string) (ResetTOTPData, error)
- func (s *Service) SetupTOTP(ctx context.Context, guard SetupTOTPGuard, userID int) (*User, error)
- func (s *Service) SetupTOTPValidate(guard SetupTOTPGuard, userID int) (SetupTOTPData, error)
- func (s *Service) SignInWithFacebook(ctx context.Context, email string, behavior FacebookSignInBehavior) (*User, bool, error)
- func (s *Service) SignInWithFacebookValidate(email string) (SignInWithFacebookData, error)
- func (s *Service) SignInWithGoogle(ctx context.Context, email string, behavior GoogleSignInBehavior) (*User, bool, error)
- func (s *Service) SignInWithGoogleValidate(email string) (SignInWithGoogleData, error)
- func (s *Service) SignInWithMagicLink(ctx context.Context, email string, behavior MagicLinkSignInBehavior) (*User, bool, error)
- func (s *Service) SignInWithMagicLinkValidate(email string) (SignInWithMagicLinkData, error)
- func (s *Service) SignInWithPassword(ctx context.Context, email, password string) (*User, error)
- func (s *Service) SignInWithPasswordValidate(email, password string) (SignInWithPasswordData, error)
- func (s *Service) SignInWithRecoveryCode(ctx context.Context, userID int, recoveryCode string) (*User, error)
- func (s *Service) SignInWithRecoveryCodeValidate(userID int, recoveryCode string) (SignInWithRecoveryCodeData, error)
- func (s *Service) SignInWithTOTP(ctx context.Context, userID int, totp string) (*User, error)
- func (s *Service) SignInWithTOTPValidate(userID int, totp string) (SignInWithTOTPData, error)
- func (s *Service) SignUp(ctx context.Context, email string) (*User, error)
- func (s *Service) SignUpInitialUser(ctx context.Context, email, password, passwordCheck string, roleIDs []int) (*User, error)
- func (s *Service) SignUpInitialUserValidate(email, password, passwordCheck string, roleIDs []int) (SignUpInitialUserData, error)
- func (s *Service) SignUpValidate(email string) (SignUpData, error)
- func (s *Service) SuspendUser(ctx context.Context, guard SuspendUsersGuard, userID int, ...) (*User, error)
- func (s *Service) SuspendUserValidate(guard SuspendUsersGuard, userID int, suspendedReason string) (SuspendUserData, error)
- func (s *Service) UnsuspendUser(ctx context.Context, guard UnsuspendUsersGuard, userID int) (*User, error)
- func (s *Service) UnsuspendUserValidate(guard UnsuspendUsersGuard, userID int) (UnsuspendUserData, error)
- func (s *Service) UpdateRole(ctx context.Context, guard UpdateRoleGuard, input UpdateRoleInput) (*Role, error)
- func (s *Service) UpdateRoleValidate(guard UpdateRoleGuard, input UpdateRoleInput) (UpdateRoleData, error)
- func (s *Service) VerifyTOTP(ctx context.Context, guard VerifyTOTPGuard, input VerifyTOTPInput) (*User, []string, error)
- func (s *Service) VerifyTOTPValidate(guard VerifyTOTPGuard, input VerifyTOTPInput) (VerifyTOTPData, error)
- func (s *Service) VerifyUser(ctx context.Context, input VerifyUserInput) (*User, error)
- func (s *Service) VerifyUserValidate(input VerifyUserInput) (VerifyUserData, error)
- type SetupTOTPData
- type SetupTOTPGuard
- type SignInAttemptLog
- type SignInThrottleError
- type SignInWithFacebookData
- type SignInWithGoogleData
- type SignInWithMagicLinkData
- type SignInWithPasswordData
- type SignInWithRecoveryCodeData
- type SignInWithTOTPData
- type SignUpData
- type SignUpInitialUserData
- type SignedIn
- type SignedUp
- type SuspendUserData
- type SuspendUsersGuard
- type Suspended
- type SuspendedReason
- type SuspendedReasonChanged
- type TOTP
- type TOTPDisabled
- type TOTPKey
- type TOTPMethod
- type TOTPReset
- type TOTPResetRequestApproved
- type TOTPResetRequestDenied
- type TOTPResetRequested
- type TOTPTelChanged
- type Tel
- type UnsuspendUserData
- type UnsuspendUsersGuard
- type Unsuspended
- type UpdateRoleData
- type UpdateRoleGuard
- type UpdateRoleInput
- type User
- func (u *User) Activate() error
- func (u *User) ActivateTOTP() error
- func (u *User) ApproveTOTPResetRequest() error
- func (u *User) ChangePassword(oldPassword, newPassword Password, hasher Hasher) error
- func (u *User) ChangeRoles(roles []*Role, grants, denials []Permission)
- func (u *User) ChangeTOTPTel(newTel Tel) error
- func (u *User) ChoosePassword(newPassword Password, hasher Hasher) error
- func (u *User) DenyTOTPResetRequest() error
- func (u *User) DisableTOTP(password Password, hasher Hasher) error
- func (u *User) GenerateTOTP() (string, error)
- func (u *User) HasActivatedTOTP() bool
- func (u *User) HasSetupTOTP() bool
- func (u *User) HasSignedIn() bool
- func (u *User) HasVerifiedTOTP() bool
- func (u *User) Invite(system string) error
- func (u *User) IsActivated() bool
- func (u *User) IsSuspended() bool
- func (u *User) IsVerified() bool
- func (u *User) Permissions() []string
- func (u *User) RegenerateRecoveryCodes(totp TOTP) ([]string, error)
- func (u *User) RequestTOTPReset() error
- func (u *User) ResetPassword(newPassword Password, hasher Hasher) error
- func (u *User) ResetTOTP(password Password, hasher Hasher) error
- func (u *User) SetupTOTP() error
- func (u *User) SignInWithFacebook(system string) error
- func (u *User) SignInWithGoogle(system string) error
- func (u *User) SignInWithMagicLink(system string) error
- func (u *User) SignInWithPassword(system string, password Password, hasher Hasher) (bool, error)
- func (u *User) SignInWithRecoveryCode(system string, code RecoveryCode) error
- func (u *User) SignInWithTOTP(system string, totp TOTP) error
- func (u *User) SignUp(system string)
- func (u *User) SignUpAsInitialUser(system string, roles []*Role, password Password, hasher Hasher) error
- func (u *User) SignUpWithFacebook(system string)
- func (u *User) SignUpWithGoogle(system string)
- func (u *User) SignUpWithMagicLink(system string)
- func (u *User) Suspend(reason SuspendedReason)
- func (u *User) Unsuspend()
- func (u *User) Verify(password Password, hasher Hasher) error
- func (u *User) VerifyTOTP(totp TOTP, method TOTPMethod) ([]string, error)
- type UserFilter
- type Verified
- type VerifyTOTPData
- type VerifyTOTPGuard
- type VerifyTOTPInput
- type VerifyUserBehavior
- type VerifyUserData
- type VerifyUserInput
- type Writer
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 ¶
Types ¶
type ActivateTOTPData ¶
type ActivateTOTPData struct {
UserID int
}
type ActivateTOTPGuard ¶
type ActivateUserData ¶
type ActivateUserData struct {
UserID int
}
type ActivateUsersGuard ¶
type ActivateUsersGuard interface {
CanActivateUsers() bool
}
type AlreadySignedUp ¶
type ApproveTOTPResetRequestData ¶
type ApproveTOTPResetRequestData struct {
UserID int
}
type ChangePasswordData ¶
type ChangePasswordGuard ¶
type ChangePasswordInput ¶
type ChangeRolesData ¶
type ChangeRolesData struct { UserID int RoleIDs []int Grants []Permission Denials []Permission }
type ChangeRolesGuard ¶
type ChangeRolesInput ¶
type ChangeTOTPTelData ¶
type ChangeTOTPTelGuard ¶
type ChoosePasswordData ¶
type ChoosePasswordGuard ¶
type ChoosePasswordInput ¶
type CreateRoleData ¶
type CreateRoleData struct { Name RoleName Description RoleDesc Permissions []Permission }
type CreateRoleGuard ¶
type CreateRoleGuard interface {
CanCreateRoles() bool
}
type CreateRoleInput ¶
type DeleteRoleData ¶
type DeleteRoleData struct {
RoleID int
}
type DeleteRoleGuard ¶
type DeleteRoleGuard interface {
CanDeleteRoles() bool
}
type DenyTOTPResetRequestData ¶
type DenyTOTPResetRequestData struct {
UserID int
}
type DisableTOTPData ¶
type DisableTOTPGuard ¶
type FacebookSignInBehavior ¶
type FacebookSignInBehavior byte
const ( FacebookSignInOnly FacebookSignInBehavior = iota FacebookAllowSignUp FacebookAllowSignUpActivate )
type GoogleSignInBehavior ¶
type GoogleSignInBehavior byte
const ( GoogleSignInOnly GoogleSignInBehavior = iota GoogleAllowSignUp GoogleAllowSignUpActivate )
type InitialUserSignedUp ¶
type InviteUserData ¶
type InviteUserData struct {
Email Email
}
type InviteUserGuard ¶
type InviteUserGuard interface {
CanInviteUsers() bool
}
type MagicLinkSignInBehavior ¶
type MagicLinkSignInBehavior byte
const ( MagicLinkSignInOnly MagicLinkSignInBehavior = iota MagicLinkAllowSignUp MagicLinkAllowSignUpActivate )
type Password ¶
type Password struct {
// contains filtered or unexported fields
}
func NewPassword ¶
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 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 RequestTOTPResetData ¶
type RequestTOTPResetData struct {
Email Email
}
type ResetPasswordData ¶
type ResetPasswordGuard ¶
type ResetPasswordInput ¶
type ResetTOTPData ¶
type ResetTOTPGuard ¶
type Role ¶
func (*Role) ChangeDescription ¶
func (*Role) ChangeName ¶
func (*Role) ChangePermissions ¶
func (r *Role) ChangePermissions(permissions []Permission)
type RoleFilter ¶
type RolesChanged ¶
type RolesChanged struct {
Email string
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) ActivateTOTP ¶
func (*Service) ActivateTOTPValidate ¶
func (s *Service) ActivateTOTPValidate(guard ActivateTOTPGuard, userID int) (ActivateTOTPData, error)
func (*Service) ActivateUser ¶
func (*Service) ActivateUserValidate ¶
func (s *Service) ActivateUserValidate(guard ActivateUsersGuard, userID int) (ActivateUserData, error)
func (*Service) ApproveTOTPResetRequest ¶
func (*Service) ApproveTOTPResetRequestValidate ¶
func (s *Service) ApproveTOTPResetRequestValidate(userID int) (ApproveTOTPResetRequestData, error)
func (*Service) ChangePassword ¶
func (s *Service) ChangePassword(ctx context.Context, guard ChangePasswordGuard, input ChangePasswordInput) (*User, error)
func (*Service) ChangePasswordValidate ¶
func (s *Service) ChangePasswordValidate(guard ChangePasswordGuard, input ChangePasswordInput) (ChangePasswordData, error)
func (*Service) ChangeRoles ¶
func (s *Service) ChangeRoles(ctx context.Context, guard ChangeRolesGuard, input ChangeRolesInput) (*User, error)
func (*Service) ChangeRolesValidate ¶
func (s *Service) ChangeRolesValidate(guard ChangeRolesGuard, input ChangeRolesInput) (ChangeRolesData, error)
func (*Service) ChangeTOTPTel ¶
func (*Service) ChangeTOTPTelValidate ¶
func (s *Service) ChangeTOTPTelValidate(guard ChangeTOTPTelGuard, userID int, newTel string) (ChangeTOTPTelData, error)
func (*Service) CheckSignInThrottle ¶
func (*Service) ChoosePassword ¶
func (s *Service) ChoosePassword(ctx context.Context, guard ChoosePasswordGuard, input ChoosePasswordInput) (*User, error)
func (*Service) ChoosePasswordValidate ¶
func (s *Service) ChoosePasswordValidate(guard ChoosePasswordGuard, input ChoosePasswordInput) (ChoosePasswordData, error)
func (*Service) CreateRole ¶
func (s *Service) CreateRole(ctx context.Context, guard CreateRoleGuard, input CreateRoleInput) (*Role, error)
func (*Service) CreateRoleValidate ¶
func (s *Service) CreateRoleValidate(guard CreateRoleGuard, input CreateRoleInput) (CreateRoleData, error)
func (*Service) DeleteRole ¶
func (*Service) DeleteRoleValidate ¶
func (s *Service) DeleteRoleValidate(guard DeleteRoleGuard, roleID int) (DeleteRoleData, error)
func (*Service) DenyTOTPResetRequest ¶
func (*Service) DenyTOTPResetRequestValidate ¶
func (s *Service) DenyTOTPResetRequestValidate(userID int) (DenyTOTPResetRequestData, error)
func (*Service) DisableTOTP ¶
func (*Service) DisableTOTPValidate ¶
func (s *Service) DisableTOTPValidate(guard DisableTOTPGuard, userID int, password string) (DisableTOTPData, error)
func (*Service) InviteUser ¶
func (*Service) InviteUserValidate ¶
func (s *Service) InviteUserValidate(guard InviteUserGuard, email string) (InviteUserData, error)
func (*Service) RegenerateRecoveryCodes ¶
func (*Service) RegenerateRecoveryCodesValidate ¶
func (s *Service) RegenerateRecoveryCodesValidate(guard RegenerateRecoveryCodesGuard, userID int, totp string) (RegenerateRecoveryCodesData, error)
func (*Service) RequestTOTPReset ¶
func (*Service) RequestTOTPResetValidate ¶
func (s *Service) RequestTOTPResetValidate(email string) (RequestTOTPResetData, error)
func (*Service) ResetPassword ¶
func (s *Service) ResetPassword(ctx context.Context, guard ResetPasswordGuard, input ResetPasswordInput) (*User, error)
func (*Service) ResetPasswordValidate ¶
func (s *Service) ResetPasswordValidate(guard ResetPasswordGuard, input ResetPasswordInput) (ResetPasswordData, error)
func (*Service) ResetTOTPValidate ¶
func (s *Service) ResetTOTPValidate(guard ResetTOTPGuard, userID int, password string) (ResetTOTPData, error)
func (*Service) SetupTOTPValidate ¶
func (s *Service) SetupTOTPValidate(guard SetupTOTPGuard, userID int) (SetupTOTPData, error)
func (*Service) SignInWithFacebook ¶
func (*Service) SignInWithFacebookValidate ¶
func (s *Service) SignInWithFacebookValidate(email string) (SignInWithFacebookData, error)
func (*Service) SignInWithGoogle ¶
func (*Service) SignInWithGoogleValidate ¶
func (s *Service) SignInWithGoogleValidate(email string) (SignInWithGoogleData, error)
func (*Service) SignInWithMagicLink ¶
func (*Service) SignInWithMagicLinkValidate ¶
func (s *Service) SignInWithMagicLinkValidate(email string) (SignInWithMagicLinkData, error)
func (*Service) SignInWithPassword ¶
func (*Service) SignInWithPasswordValidate ¶
func (s *Service) SignInWithPasswordValidate(email, password string) (SignInWithPasswordData, error)
func (*Service) SignInWithRecoveryCode ¶
func (*Service) SignInWithRecoveryCodeValidate ¶
func (s *Service) SignInWithRecoveryCodeValidate(userID int, recoveryCode string) (SignInWithRecoveryCodeData, error)
func (*Service) SignInWithTOTP ¶
func (*Service) SignInWithTOTPValidate ¶
func (s *Service) SignInWithTOTPValidate(userID int, totp string) (SignInWithTOTPData, error)
func (*Service) SignUpInitialUser ¶
func (*Service) SignUpInitialUserValidate ¶
func (s *Service) SignUpInitialUserValidate(email, password, passwordCheck string, roleIDs []int) (SignUpInitialUserData, error)
func (*Service) SignUpValidate ¶
func (s *Service) SignUpValidate(email string) (SignUpData, error)
func (*Service) SuspendUser ¶
func (*Service) SuspendUserValidate ¶
func (s *Service) SuspendUserValidate(guard SuspendUsersGuard, userID int, suspendedReason string) (SuspendUserData, error)
func (*Service) UnsuspendUser ¶
func (*Service) UnsuspendUserValidate ¶
func (s *Service) UnsuspendUserValidate(guard UnsuspendUsersGuard, userID int) (UnsuspendUserData, error)
func (*Service) UpdateRole ¶
func (s *Service) UpdateRole(ctx context.Context, guard UpdateRoleGuard, input UpdateRoleInput) (*Role, error)
func (*Service) UpdateRoleValidate ¶
func (s *Service) UpdateRoleValidate(guard UpdateRoleGuard, input UpdateRoleInput) (UpdateRoleData, error)
func (*Service) VerifyTOTP ¶
func (s *Service) VerifyTOTP(ctx context.Context, guard VerifyTOTPGuard, input VerifyTOTPInput) (*User, []string, error)
func (*Service) VerifyTOTPValidate ¶
func (s *Service) VerifyTOTPValidate(guard VerifyTOTPGuard, input VerifyTOTPInput) (VerifyTOTPData, error)
func (*Service) VerifyUser ¶
func (*Service) VerifyUserValidate ¶
func (s *Service) VerifyUserValidate(input VerifyUserInput) (VerifyUserData, error)
type SetupTOTPData ¶
type SetupTOTPData struct {
UserID int
}
type SetupTOTPGuard ¶
type SignInAttemptLog ¶
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 SignInWithFacebookData ¶
type SignInWithFacebookData struct {
Email Email
}
type SignInWithGoogleData ¶
type SignInWithGoogleData struct {
Email Email
}
type SignInWithMagicLinkData ¶
type SignInWithMagicLinkData struct {
Email Email
}
type SignInWithPasswordData ¶
type SignInWithRecoveryCodeData ¶
type SignInWithRecoveryCodeData struct { UserID int RecoveryCode RecoveryCode }
type SignInWithTOTPData ¶
type SignUpData ¶
type SignUpData struct {
Email Email
}
type SignUpInitialUserData ¶
type SuspendUserData ¶
type SuspendUserData struct { UserID int SuspendedReason SuspendedReason }
type SuspendUsersGuard ¶
type SuspendUsersGuard interface {
CanSuspendUsers() bool
}
type SuspendedReason ¶
type SuspendedReason string
func NewSuspendedReason ¶
func NewSuspendedReason(reason string) (SuspendedReason, error)
func (SuspendedReason) String ¶
func (s SuspendedReason) String() string
type SuspendedReasonChanged ¶
type TOTPDisabled ¶
type TOTPDisabled struct {
Email string
}
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 TOTPResetRequestApproved ¶
type TOTPResetRequestApproved struct {
Email string
}
type TOTPResetRequestDenied ¶
type TOTPResetRequestDenied struct {
Email string
}
type TOTPResetRequested ¶
type TOTPResetRequested struct {
Email string
}
type TOTPTelChanged ¶
type UnsuspendUserData ¶
type UnsuspendUserData struct {
UserID int
}
type UnsuspendUsersGuard ¶
type UnsuspendUsersGuard interface {
CanUnsuspendUsers() bool
}
type Unsuspended ¶
type Unsuspended struct {
Email string
}
type UpdateRoleData ¶
type UpdateRoleData struct { RoleID int Name RoleName Description RoleDesc Permissions []Permission }
type UpdateRoleGuard ¶
type UpdateRoleGuard interface {
CanUpdateRoles() bool
}
type UpdateRoleInput ¶
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 (*User) ActivateTOTP ¶
func (*User) ApproveTOTPResetRequest ¶
func (*User) ChangePassword ¶
func (*User) ChangeRoles ¶
func (u *User) ChangeRoles(roles []*Role, grants, denials []Permission)
func (*User) ChangeTOTPTel ¶
func (*User) ChoosePassword ¶
func (*User) DenyTOTPResetRequest ¶
func (*User) GenerateTOTP ¶
func (*User) HasActivatedTOTP ¶
func (*User) HasSetupTOTP ¶
func (*User) HasSignedIn ¶
func (*User) HasVerifiedTOTP ¶
func (*User) IsActivated ¶
func (*User) IsSuspended ¶
func (*User) IsVerified ¶
func (*User) Permissions ¶
func (*User) RegenerateRecoveryCodes ¶
func (*User) RequestTOTPReset ¶
func (*User) ResetPassword ¶
func (*User) SignInWithFacebook ¶
func (*User) SignInWithGoogle ¶
func (*User) SignInWithMagicLink ¶
func (*User) SignInWithPassword ¶
func (*User) SignInWithRecoveryCode ¶
func (u *User) SignInWithRecoveryCode(system string, code RecoveryCode) error
func (*User) SignUpAsInitialUser ¶
func (*User) SignUpWithFacebook ¶
func (*User) SignUpWithGoogle ¶
func (*User) SignUpWithMagicLink ¶
func (*User) Suspend ¶
func (u *User) Suspend(reason SuspendedReason)
func (*User) VerifyTOTP ¶
func (u *User) VerifyTOTP(totp TOTP, method TOTPMethod) ([]string, error)
type UserFilter ¶
type VerifyTOTPData ¶
type VerifyTOTPData struct { UserID int TOTP TOTP TOTPMethod TOTPMethod }
type VerifyTOTPGuard ¶
type VerifyTOTPInput ¶
type VerifyUserBehavior ¶
type VerifyUserBehavior byte
const ( VerifyUserOnly VerifyUserBehavior = iota VerifyUserActivate )
type VerifyUserData ¶
type VerifyUserData struct { Email Email Password Password PasswordCheck Password Behavior VerifyUserBehavior }
type VerifyUserInput ¶
type VerifyUserInput struct { Email string Password string PasswordCheck string Behavior VerifyUserBehavior }
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 }
Source Files
¶
- activate_totp.go
- activate_user.go
- approve_totp_reset_request.go
- change_password.go
- change_roles.go
- change_totp_telephone.go
- choose_password.go
- create_role.go
- delete_role.go
- deny_totp_reset_request.go
- disable_totp.go
- email.go
- events.go
- invite_user.go
- password.go
- permission.go
- recovery_code.go
- regen_recovery_codes.go
- repo.go
- request_totp_reset.go
- reset_password.go
- reset_totp.go
- role.go
- role_desc.go
- role_name.go
- service.go
- setup_totp.go
- sign_in_attempt_log.go
- sign_in_facebook.go
- sign_in_google.go
- sign_in_magic_link.go
- sign_in_password.go
- sign_in_recovery_code.go
- sign_in_totp.go
- sign_up.go
- sign_up_initial_user.go
- suspend.go
- suspend_reason.go
- tel.go
- totp.go
- totp_key.go
- totp_method.go
- unsuspend.go
- update_role.go
- user.go
- verify_totp.go
- verify_user.go
Click to show internal directories.
Click to hide internal directories.