Documentation ¶
Index ¶
- Constants
- Variables
- func GetCurrentUser(r *http.Request) (u interface{})
- func GetSessionToken(b *Builder, r *http.Request) string
- func IsLoginWIP(r *http.Request) bool
- func MustSetQuery(u string, keyVals ...string) string
- func RevokeTOTP(ssup SessionSecureUserPasser, db *gorm.DB, userModel interface{}, ...) (err error)
- type Builder
- func (b *Builder) AfterChangePassword(v HookFunc) (r *Builder)
- func (b *Builder) AfterConfirmSendResetPasswordLink(v HookFunc) (r *Builder)
- func (b *Builder) AfterExtendSession(v HookFunc) (r *Builder)
- func (b *Builder) AfterFailedToLogin(v HookFunc) (r *Builder)
- func (b *Builder) AfterLogin(v HookFunc) (r *Builder)
- func (b *Builder) AfterLogout(v HookFunc) (r *Builder)
- func (b *Builder) AfterOAuthComplete(v HookFunc) (r *Builder)
- func (b *Builder) AfterResetPassword(v HookFunc) (r *Builder)
- func (b *Builder) AfterTOTPCodeReused(v HookFunc) (r *Builder)
- func (b *Builder) AfterUserLocked(v HookFunc) (r *Builder)
- func (b *Builder) AuthCookieName(v string) (r *Builder)
- func (b *Builder) AutoExtendSession(v bool) (r *Builder)
- func (b *Builder) BeforeSetPassword(v HookFunc) (r *Builder)
- func (b *Builder) ChangePassword(r *http.Request, oldPassword string, password string, confirmPassword string, ...) error
- func (b *Builder) ChangePasswordPageFunc(v web.PageFunc) (r *Builder)
- func (b *Builder) ChangePasswordPageURL(v string) (r *Builder)
- func (b *Builder) CookieConfig(v CookieConfig) (r *Builder)
- func (b *Builder) DB(v *gorm.DB) (r *Builder)
- func (b *Builder) ForgetPasswordPageFunc(v web.PageFunc) (r *Builder)
- func (b *Builder) ForgetPasswordPageURL(v string) (r *Builder)
- func (b *Builder) GetSessionMaxAge() int
- func (b *Builder) HomeURLFunc(v HomeURLFunc) (r *Builder)
- func (b *Builder) I18n(v *i18n.Builder) (r *Builder)
- func (b *Builder) LoginPageFunc(v web.PageFunc) (r *Builder)
- func (b *Builder) LoginPageURL(v string) (r *Builder)
- func (b *Builder) MaxRetryCount(v int) (r *Builder)
- func (b *Builder) Middleware(cfgs ...MiddlewareConfig) func(next http.Handler) http.Handler
- func (b *Builder) Mount(mux *http.ServeMux)
- func (b *Builder) MountAPI(mux *http.ServeMux)
- func (b *Builder) NoForgetPasswordLink(v bool) (r *Builder)
- func (b *Builder) OAuthIdentifier(provider string, identifier OAuthIdentifier) (r *Builder)
- func (b *Builder) OAuthProviders(vs ...*Provider) (r *Builder)
- func (b *Builder) Recaptcha(enable bool, config ...RecaptchaConfig) (r *Builder)
- func (b *Builder) ResetPasswordLinkSentPageFunc(v web.PageFunc) (r *Builder)
- func (b *Builder) ResetPasswordLinkSentPageURL(v string) (r *Builder)
- func (b *Builder) ResetPasswordPageFunc(v web.PageFunc) (r *Builder)
- func (b *Builder) ResetPasswordPageURL(v string) (r *Builder)
- func (b *Builder) Secret(v string) (r *Builder)
- func (b *Builder) SessionMaxAge(v int) (r *Builder)
- func (b *Builder) TOTP(enable bool, config ...TOTPConfig) (r *Builder)
- func (b *Builder) TOTPSetupPageFunc(v web.PageFunc) (r *Builder)
- func (b *Builder) TOTPSetupPageURL(v string) (r *Builder)
- func (b *Builder) TOTPValidatePageFunc(v web.PageFunc) (r *Builder)
- func (b *Builder) TOTPValidatePageURL(v string) (r *Builder)
- func (b *Builder) URIPrefix(v string) (r *Builder)
- func (b *Builder) UserModel(m interface{}) (r *Builder)
- func (b *Builder) ViewHelper() *ViewHelper
- type ContextUserKey
- type CookieConfig
- type DisableAutoRedirectToHomePage
- type FailCode
- type HomeURLFunc
- type HookFunc
- type InfoCode
- type LoginNotRequired
- type Messages
- type MiddlewareConfig
- type NoticeError
- type NoticeLevel
- type OAuthIdentifier
- type OAuthInfo
- func (oa *OAuthInfo) FindUserByOAuthIdentifier(db *gorm.DB, model interface{}, provider string, identifier string) (user interface{}, err error)
- func (oa *OAuthInfo) FindUserByOAuthUserID(db *gorm.DB, model interface{}, provider string, oid string) (user interface{}, err error)
- func (oa *OAuthInfo) GetAvatar() string
- func (oa *OAuthInfo) InitOAuthUserID(db *gorm.DB, model interface{}, provider string, identifier string, oid string) error
- func (oa *OAuthInfo) SetAvatar(v string)
- type OAuthUser
- type PrimaryFielder
- type Provider
- type RecaptchaConfig
- type SessionSecure
- type SessionSecureUserPasser
- type SessionSecurer
- type TOTPConfig
- type UserClaims
- type UserPass
- func (up *UserPass) ConsumeResetPasswordToken(db *gorm.DB, model interface{}) error
- func (up *UserPass) EncryptPassword()
- func (up *UserPass) FindUser(db *gorm.DB, model interface{}, account string) (user interface{}, err error)
- func (up *UserPass) GenerateResetPasswordToken(db *gorm.DB, model interface{}) (token string, err error)
- func (up *UserPass) GetAccountName() string
- func (up *UserPass) GetIsTOTPSetup() bool
- func (up *UserPass) GetLastUsedTOTPCode() (code string, usedAt *time.Time)
- func (up *UserPass) GetLocked() bool
- func (up *UserPass) GetLoginRetryCount() int
- func (up *UserPass) GetPasswordUpdatedAt() string
- func (up *UserPass) GetResetPasswordToken() (token string, createdAt *time.Time, expired bool)
- func (up *UserPass) GetTOTPSecret() string
- func (up *UserPass) IncreaseRetryCount(db *gorm.DB, model interface{}) error
- func (up *UserPass) IsPasswordCorrect(password string) bool
- func (up *UserPass) LockUser(db *gorm.DB, model interface{}) error
- func (up *UserPass) SetIsTOTPSetup(db *gorm.DB, model interface{}, v bool) error
- func (up *UserPass) SetLastUsedTOTPCode(db *gorm.DB, model interface{}, passcode string) error
- func (up *UserPass) SetPassword(db *gorm.DB, model interface{}, password string) error
- func (up *UserPass) SetTOTPSecret(db *gorm.DB, model interface{}, key string) error
- func (up *UserPass) UnlockUser(db *gorm.DB, model interface{}) error
- type UserPasser
- type ViewCommon
- func (vc *ViewCommon) ErrNotice(msg string) HTMLComponent
- func (vc *ViewCommon) ErrorBody(msg string) HTMLComponent
- func (vc *ViewCommon) InfoNotice(msg string) HTMLComponent
- func (vc *ViewCommon) Notice(vh *ViewHelper, msgr *Messages, w http.ResponseWriter, r *http.Request) HTMLComponent
- func (vc *ViewCommon) PasswordInputWithRevealFunction(name string, placeholder string, id string, val string) HTMLComponent
- func (vc *ViewCommon) PasswordStrengthMeter(inputID string) HTMLComponent
- func (vc *ViewCommon) WarnNotice(msg string) HTMLComponent
- type ViewHelper
- func (vh *ViewHelper) ChangePasswordURL() string
- func (vh *ViewHelper) FindUserByID(id string) (user interface{}, err error)
- func (vh *ViewHelper) ForgetPasswordPageURL() string
- func (vh *ViewHelper) GetFailCodeFlash(w http.ResponseWriter, r *http.Request) FailCode
- func (vh *ViewHelper) GetFailFlashMessage(msgr *Messages, w http.ResponseWriter, r *http.Request) string
- func (vh *ViewHelper) GetInfoCodeFlash(w http.ResponseWriter, r *http.Request) InfoCode
- func (vh *ViewHelper) GetInfoFlashMessage(msgr *Messages, w http.ResponseWriter, r *http.Request) string
- func (vh *ViewHelper) GetNoticeFlash(w http.ResponseWriter, r *http.Request) *NoticeError
- func (vh *ViewHelper) GetSecondsToRedoFlash(w http.ResponseWriter, r *http.Request) int
- func (vh *ViewHelper) GetWarnCodeFlash(w http.ResponseWriter, r *http.Request) WarnCode
- func (vh *ViewHelper) GetWarnFlashMessage(msgr *Messages, w http.ResponseWriter, r *http.Request) string
- func (vh *ViewHelper) GetWrongChangePasswordInputFlash(w http.ResponseWriter, r *http.Request) WrongChangePasswordInputFlash
- func (vh *ViewHelper) GetWrongForgetPasswordInputFlash(w http.ResponseWriter, r *http.Request) WrongForgetPasswordInputFlash
- func (vh *ViewHelper) GetWrongLoginInputFlash(w http.ResponseWriter, r *http.Request) WrongLoginInputFlash
- func (vh *ViewHelper) GetWrongResetPasswordInputFlash(w http.ResponseWriter, r *http.Request) WrongResetPasswordInputFlash
- func (vh *ViewHelper) I18n() *i18n.Builder
- func (vh *ViewHelper) NoForgetPasswordLink() bool
- func (vh *ViewHelper) OAuthBeginURL() string
- func (vh *ViewHelper) OAuthEnabled() bool
- func (vh *ViewHelper) OAuthProviders() []*Provider
- func (vh *ViewHelper) PasswordLoginURL() string
- func (vh *ViewHelper) RecaptchaEnabled() bool
- func (vh *ViewHelper) RecaptchaSiteKey() string
- func (vh *ViewHelper) ResetPasswordURL() string
- func (vh *ViewHelper) SendResetPasswordLinkURL() string
- func (vh *ViewHelper) TOTPEnabled() bool
- func (vh *ViewHelper) TOTPIssuer() string
- func (vh *ViewHelper) UserPassEnabled() bool
- func (vh *ViewHelper) ValidateTOTPURL() string
- type WarnCode
- type WrongChangePasswordInputFlash
- type WrongForgetPasswordInputFlash
- type WrongLoginInputFlash
- type WrongResetPasswordInputFlash
Constants ¶
const I18nLoginKey i18n.ModuleKey = "I18nLoginKey"
const (
WarnCodePasswordHasBeenChanged = iota + 1
)
Variables ¶
var ( StyleCSSURL = assetsPathPrefix + "style.css" ZxcvbnJSURL = assetsPathPrefix + "zxcvbn.js" )
var ( ErrUserNotFound = errors.New("user not found") ErrPasswordChanged = errors.New("password changed") ErrWrongPassword = errors.New("wrong password") ErrUserLocked = errors.New("user locked") ErrUserGetLocked = errors.New("user get locked") ErrWrongTOTPCode = errors.New("wrong totp code") ErrTOTPCodeHasBeenUsed = errors.New("totp code has been used") ErrEmptyPassword = errors.New("empty password") ErrPasswordNotMatch = errors.New("password not match") )
var DefaultViewCommon = &ViewCommon{
WrapperClass: "flex pt-16 flex-col max-w-md mx-auto",
TitleClass: "leading-tight text-3xl mt-0 mb-6",
LabelClass: "block mb-2 text-sm text-gray-600 dark:text-gray-200",
InputClass: "block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-400 bg-white border border-gray-200 rounded-md dark:placeholder-gray-600 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700 focus:border-blue-400 dark:focus:border-blue-400 focus:ring-blue-400 focus:outline-none focus:ring focus:ring-opacity-40",
ButtonClass: "w-full px-6 py-3 tracking-wide text-white transition-colors duration-200 transform bg-blue-500 rounded-md hover:bg-blue-400 focus:outline-none focus:bg-blue-400 focus:ring focus:ring-blue-300 focus:ring-opacity-50",
}
var Messages_en_US = &Messages{
Confirm: "Confirm",
Verify: "Verify",
LoginPageTitle: "Sign In",
AccountLabel: "Email",
AccountPlaceholder: "Email",
PasswordLabel: "Password",
PasswordPlaceholder: "Password",
SignInBtn: "Sign In",
ForgetPasswordLink: "Forget your password?",
ForgetPasswordPageTitle: "Forget Your Password?",
ForgotMyPasswordTitle: "I forgot my password",
ForgetPasswordEmailLabel: "Enter your email",
ForgetPasswordEmailPlaceholder: "Email",
SendResetPasswordEmailBtn: "Send reset password email",
ResendResetPasswordEmailBtn: "Resend reset password email",
SendEmailTooFrequentlyNotice: "Sending emails too frequently, please try again later",
ResetPasswordLinkSentPageTitle: "Forget Your Password?",
ResetPasswordLinkWasSentTo: "A reset password link was sent to",
ResetPasswordLinkSentPrompt: "You can close this page and reset your password from this link.",
ResetPasswordPageTitle: "Reset Password",
ResetYourPasswordTitle: "Reset your password",
ResetPasswordLabel: "Change your password",
ResetPasswordPlaceholder: "New password",
ResetPasswordConfirmLabel: "Re-enter new password",
ResetPasswordConfirmPlaceholder: "Confirm new password",
ChangePasswordPageTitle: "Change Password",
ChangePasswordTitle: "Change your password",
ChangePasswordOldLabel: "Old password",
ChangePasswordOldPlaceholder: "Old Password",
ChangePasswordNewLabel: "New password",
ChangePasswordNewPlaceholder: "New Password",
ChangePasswordNewConfirmLabel: "Re-enter new password",
ChangePasswordNewConfirmPlaceholder: "New Password",
TOTPSetupPageTitle: "TOTP Setup",
TOTPSetupTitle: "Two Factor Authentication",
TOTPSetupScanPrompt: "Scan this QR code with Google Authenticator (or similar) app",
TOTPSetupSecretPrompt: "Or manually enter the following code into your preferred authenticator app",
TOTPSetupEnterCodePrompt: "Then enter the provided one-time code below",
TOTPSetupCodePlaceholder: "Passcode",
TOTPValidatePageTitle: "TOTP Validate",
TOTPValidateTitle: "Two Factor Authentication",
TOTPValidateEnterCodePrompt: "Enter the provided one-time code below",
TOTPValidateCodeLabel: "Authenticator passcode",
TOTPValidateCodePlaceholder: "Passcode",
ErrorSystemError: "System Error",
ErrorCompleteUserAuthFailed: "Complete User Auth Failed",
ErrorUserNotFound: "User Not Found",
ErrorIncorrectAccountNameOrPassword: "Incorrect email or password",
ErrorUserLocked: "User Locked",
ErrorAccountIsRequired: "Email is required",
ErrorPasswordCannotBeEmpty: "Password cannot be empty",
ErrorPasswordNotMatch: "Password do not match",
ErrorIncorrectPassword: "Old password is incorrect",
ErrorInvalidToken: "Invalid token",
ErrorTokenExpired: "Token expired",
ErrorIncorrectTOTPCode: "Incorrect passcode",
ErrorTOTPCodeReused: "This passcode has been used",
ErrorIncorrectRecaptchaToken: "Incorrect reCAPTCHA token",
WarnPasswordHasBeenChanged: "Password has been changed, please sign-in again",
InfoPasswordSuccessfullyReset: "Password successfully reset, please sign-in again",
InfoPasswordSuccessfullyChanged: "Password successfully changed, please sign-in again",
}
var Messages_ja_JP = &Messages{
Confirm: "確認する",
Verify: "検証",
LoginPageTitle: "ログイン",
AccountLabel: "メールアドレス",
AccountPlaceholder: "メールアドレス",
PasswordLabel: "パスワード",
PasswordPlaceholder: "パスワード",
SignInBtn: "ログイン",
ForgetPasswordLink: "パスワードをお忘れですか?",
ForgetPasswordPageTitle: "パスワードをお忘れですか?",
ForgotMyPasswordTitle: "パスワードを忘れました",
ForgetPasswordEmailLabel: "メールアドレスを入力してください",
ForgetPasswordEmailPlaceholder: "メールアドレス",
SendResetPasswordEmailBtn: "パスワードリセット用メールが送信されました",
ResendResetPasswordEmailBtn: "パスワードリセット用メールを再送する",
SendEmailTooFrequentlyNotice: "メール送信回数が上限を超えています。しばらく経ってから再度お試しください",
ResetPasswordLinkSentPageTitle: "パスワードをお忘れですか?",
ResetPasswordLinkWasSentTo: "パスワードリセット用リンクが送信されました",
ResetPasswordLinkSentPrompt: "このリンクからパスワードリセット手続きを行い、終了後はページを閉じてください",
ResetPasswordPageTitle: "パスワードをリセットしてください",
ResetYourPasswordTitle: "パスワードをリセットしてください",
ResetPasswordLabel: "パスワードを変更する",
ResetPasswordPlaceholder: "新しいパスワード",
ResetPasswordConfirmLabel: "新しいパスワードを再入力",
ResetPasswordConfirmPlaceholder: "新しいパスワードを確認する",
ChangePasswordPageTitle: "パスワードを変更する",
ChangePasswordTitle: "パスワードを変更する",
ChangePasswordOldLabel: "古いパスワード",
ChangePasswordOldPlaceholder: "古いパスワード",
ChangePasswordNewLabel: "新しいパスワード",
ChangePasswordNewPlaceholder: "新しいパスワード",
ChangePasswordNewConfirmLabel: "新しいパスワードを再入力する",
ChangePasswordNewConfirmPlaceholder: "新しいパスワード",
TOTPSetupPageTitle: "二段階認証",
TOTPSetupTitle: "二段階認証",
TOTPSetupScanPrompt: "Google認証アプリ(または同等アプリ)を利用してこのQRコードをスキャンしてください",
TOTPSetupSecretPrompt: "または、お好きな認証アプリを利用して、以下のコードを入力してください",
TOTPSetupEnterCodePrompt: "以下のワンタイムコードを入力してください",
TOTPSetupCodePlaceholder: "パスコード",
TOTPValidatePageTitle: "二段階認証",
TOTPValidateTitle: "二段階認証",
TOTPValidateEnterCodePrompt: "提供されたワンタイムコードを以下に入力してください",
TOTPValidateCodeLabel: "認証パスコード",
TOTPValidateCodePlaceholder: "パスコード",
ErrorSystemError: "システムエラー",
ErrorCompleteUserAuthFailed: "ユーザー認証に失敗しました",
ErrorUserNotFound: "このユーザーは存在しません",
ErrorIncorrectAccountNameOrPassword: "メールアドレスまたはパスワードが間違っています",
ErrorUserLocked: "ユーザーがロックされました",
ErrorAccountIsRequired: "メールアドレスは必須です",
ErrorPasswordCannotBeEmpty: "パスワードは必須です",
ErrorPasswordNotMatch: "パスワードが間違っています",
ErrorIncorrectPassword: "古いパスワードが間違っています",
ErrorInvalidToken: "このトークンは無効です",
ErrorTokenExpired: "トークンの有効期限が切れています",
ErrorIncorrectTOTPCode: "パスコードが間違っています",
ErrorTOTPCodeReused: "このパスコードは既に利用されています",
ErrorIncorrectRecaptchaToken: "reCAPTCHAトークンが間違っています",
WarnPasswordHasBeenChanged: "パスワードが変更されました。再度ログインしてください",
InfoPasswordSuccessfullyReset: "パスワードのリセットに成功しました。再度ログインしてください",
InfoPasswordSuccessfullyChanged: "パスワードの変更に成功しました。再度ログインしてください",
}
var Messages_zh_CN = &Messages{
Confirm: "确认",
Verify: "验证",
LoginPageTitle: "登录",
AccountLabel: "邮箱",
AccountPlaceholder: "邮箱",
PasswordLabel: "密码",
PasswordPlaceholder: "密码",
SignInBtn: "登录",
ForgetPasswordLink: "忘记密码?",
ForgetPasswordPageTitle: "忘记密码?",
ForgotMyPasswordTitle: "我忘记密码了",
ForgetPasswordEmailLabel: "输入您的电子邮箱",
ForgetPasswordEmailPlaceholder: "电子邮箱",
SendResetPasswordEmailBtn: "发送重置密码电子邮件",
ResendResetPasswordEmailBtn: "重新发送重置密码电子邮件",
SendEmailTooFrequentlyNotice: "邮件发送过于频繁,请稍后再试",
ResetPasswordLinkSentPageTitle: "忘记密码?",
ResetPasswordLinkWasSentTo: "已将重置密码链接发送到",
ResetPasswordLinkSentPrompt: "您可以关闭此页面并从此链接重置密码。",
ResetPasswordPageTitle: "重置密码",
ResetYourPasswordTitle: "重置您的密码",
ResetPasswordLabel: "改变您的密码",
ResetPasswordPlaceholder: "新密码",
ResetPasswordConfirmLabel: "再次输入新密码",
ResetPasswordConfirmPlaceholder: "新密码",
ChangePasswordPageTitle: "修改密码",
ChangePasswordTitle: "修改您的密码",
ChangePasswordOldLabel: "旧密码",
ChangePasswordOldPlaceholder: "旧密码",
ChangePasswordNewLabel: "新密码",
ChangePasswordNewPlaceholder: "新密码",
ChangePasswordNewConfirmLabel: "再次输入新密码",
ChangePasswordNewConfirmPlaceholder: "新密码",
TOTPSetupPageTitle: "双重认证",
TOTPSetupTitle: "双重认证",
TOTPSetupScanPrompt: "使用Google Authenticator(或类似)应用程序扫描此二维码",
TOTPSetupSecretPrompt: "或者将以下代码手动输入到您首选的验证器应用程序中",
TOTPSetupEnterCodePrompt: "然后在下面输入提供的一次性代码",
TOTPSetupCodePlaceholder: "passcode",
TOTPValidatePageTitle: "双重认证",
TOTPValidateTitle: "双重认证",
TOTPValidateEnterCodePrompt: "在下面输入提供的一次性代码",
TOTPValidateCodeLabel: "Authenticator验证码",
TOTPValidateCodePlaceholder: "passcode",
ErrorSystemError: "系统错误",
ErrorCompleteUserAuthFailed: "用户认证失败",
ErrorUserNotFound: "找不到该用户",
ErrorIncorrectAccountNameOrPassword: "邮箱或密码错误",
ErrorUserLocked: "用户已锁定",
ErrorAccountIsRequired: "邮箱是必须的",
ErrorPasswordCannotBeEmpty: "密码不能为空",
ErrorPasswordNotMatch: "确认密码不匹配",
ErrorIncorrectPassword: "密码错误",
ErrorInvalidToken: "token无效",
ErrorTokenExpired: "token过期",
ErrorIncorrectTOTPCode: "passcode错误",
ErrorTOTPCodeReused: "这个passcode已经被使用过了",
ErrorIncorrectRecaptchaToken: "reCAPTCHA token错误",
WarnPasswordHasBeenChanged: "密码被修改了,请重新登录",
InfoPasswordSuccessfullyReset: "密码重置成功,请重新登录",
InfoPasswordSuccessfullyChanged: "密码修改成功,请重新登录",
}
Functions ¶
func GetCurrentUser ¶
func IsLoginWIP ¶
IsLoginWIP indicates whether the user is in an intermediate step of login process, such as on the TOTP validation page
func MustSetQuery ¶
func RevokeTOTP ¶
func RevokeTOTP( ssup SessionSecureUserPasser, db *gorm.DB, userModel interface{}, userID string, ) (err error)
Types ¶
type Builder ¶
type Builder struct { LogoutURL string // contains filtered or unexported fields }
func (*Builder) AfterChangePassword ¶
func (*Builder) AfterConfirmSendResetPasswordLink ¶
extra vals: - reset link
func (*Builder) AfterExtendSession ¶
extra vals: - old session token
func (*Builder) AfterFailedToLogin ¶
extra vals: - login error
func (*Builder) AfterLogin ¶
func (*Builder) AfterLogout ¶
func (*Builder) AfterOAuthComplete ¶
user is goth.User
func (*Builder) AfterResetPassword ¶
func (*Builder) AfterTOTPCodeReused ¶
func (*Builder) AfterUserLocked ¶
func (*Builder) AuthCookieName ¶
func (*Builder) AutoExtendSession ¶
extend the session if successfully authenticated default true
func (*Builder) BeforeSetPassword ¶
extra vals: - password
func (*Builder) ChangePassword ¶
func (b *Builder) ChangePassword( r *http.Request, oldPassword string, password string, confirmPassword string, otp string, ) error
NoticeError ErrWrongPassword ErrEmptyPassword ErrPasswordNotMatch ErrWrongTOTPCode ErrTOTPCodeHasBeenUsed
func (*Builder) ChangePasswordPageFunc ¶
func (*Builder) ChangePasswordPageURL ¶
func (*Builder) CookieConfig ¶
func (b *Builder) CookieConfig(v CookieConfig) (r *Builder)
func (*Builder) ForgetPasswordPageFunc ¶
func (*Builder) ForgetPasswordPageURL ¶
func (*Builder) GetSessionMaxAge ¶
func (*Builder) HomeURLFunc ¶
func (b *Builder) HomeURLFunc(v HomeURLFunc) (r *Builder)
func (*Builder) LoginPageURL ¶
func (*Builder) MaxRetryCount ¶
default 5 MaxRetryCount <= 0 means no max retry count limit
func (*Builder) Middleware ¶
func (*Builder) NoForgetPasswordLink ¶
func (*Builder) OAuthIdentifier ¶
func (b *Builder) OAuthIdentifier(provider string, identifier OAuthIdentifier) (r *Builder)
OAuthIdentifier is an externally-facing account identifier, such as an email address for a Google account. default is email, fallback is userID
func (*Builder) OAuthProviders ¶
func (*Builder) Recaptcha ¶
func (b *Builder) Recaptcha(enable bool, config ...RecaptchaConfig) (r *Builder)
Google reCAPTCHA.
func (*Builder) ResetPasswordLinkSentPageFunc ¶
func (*Builder) ResetPasswordLinkSentPageURL ¶
func (*Builder) ResetPasswordPageFunc ¶
func (*Builder) ResetPasswordPageURL ¶
func (*Builder) SessionMaxAge ¶
seconds default 1h
func (*Builder) TOTPSetupPageFunc ¶
func (*Builder) TOTPSetupPageURL ¶
func (*Builder) TOTPValidatePageFunc ¶
func (*Builder) TOTPValidatePageURL ¶
func (*Builder) ViewHelper ¶
func (b *Builder) ViewHelper() *ViewHelper
type DisableAutoRedirectToHomePage ¶
type DisableAutoRedirectToHomePage struct{}
DisableAutoRedirectToHomePage makes it possible to visit login page when user is logged in
type FailCode ¶
type FailCode int
const ( FailCodeSystemError FailCode = iota + 1 FailCodeCompleteUserAuthFailed FailCodeUserNotFound FailCodeIncorrectAccountNameOrPassword FailCodeUserLocked FailCodeAccountIsRequired FailCodePasswordCannotBeEmpty FailCodePasswordNotMatch FailCodeIncorrectPassword FailCodeInvalidToken FailCodeTokenExpired FailCodeIncorrectTOTPCode FailCodeTOTPCodeHasBeenUsed FailCodeIncorrectRecaptchaToken )
type HomeURLFunc ¶
type LoginNotRequired ¶
type LoginNotRequired struct{}
LoginNotRequired executes the next handler regardless of whether the user is logged in or not
type Messages ¶
type Messages struct { // common Confirm string Verify string // login page LoginPageTitle string AccountLabel string AccountPlaceholder string PasswordLabel string PasswordPlaceholder string SignInBtn string ForgetPasswordLink string // forget password page ForgetPasswordPageTitle string ForgotMyPasswordTitle string ForgetPasswordEmailLabel string ForgetPasswordEmailPlaceholder string SendResetPasswordEmailBtn string ResendResetPasswordEmailBtn string SendEmailTooFrequentlyNotice string // reset password link sent page ResetPasswordLinkSentPageTitle string ResetPasswordLinkWasSentTo string ResetPasswordLinkSentPrompt string // reset password page ResetPasswordPageTitle string ResetYourPasswordTitle string ResetPasswordLabel string ResetPasswordPlaceholder string ResetPasswordConfirmLabel string ResetPasswordConfirmPlaceholder string // change password page ChangePasswordPageTitle string ChangePasswordTitle string ChangePasswordOldLabel string ChangePasswordOldPlaceholder string ChangePasswordNewLabel string ChangePasswordNewPlaceholder string ChangePasswordNewConfirmLabel string ChangePasswordNewConfirmPlaceholder string // TOTP setup page TOTPSetupPageTitle string TOTPSetupTitle string TOTPSetupScanPrompt string TOTPSetupSecretPrompt string TOTPSetupEnterCodePrompt string TOTPSetupCodePlaceholder string // TOTP validate page TOTPValidatePageTitle string TOTPValidateTitle string TOTPValidateEnterCodePrompt string TOTPValidateCodeLabel string TOTPValidateCodePlaceholder string // Error Messages ErrorSystemError string ErrorCompleteUserAuthFailed string ErrorUserNotFound string ErrorIncorrectAccountNameOrPassword string ErrorUserLocked string ErrorAccountIsRequired string ErrorPasswordCannotBeEmpty string ErrorPasswordNotMatch string ErrorIncorrectPassword string ErrorInvalidToken string ErrorTokenExpired string ErrorIncorrectTOTPCode string ErrorTOTPCodeReused string ErrorIncorrectRecaptchaToken string // Warn Messages WarnPasswordHasBeenChanged string // Info Messages InfoPasswordSuccessfullyReset string InfoPasswordSuccessfullyChanged string }
type MiddlewareConfig ¶
type MiddlewareConfig interface {
// contains filtered or unexported methods
}
type NoticeError ¶
type NoticeError struct { Level NoticeLevel Message string }
func (*NoticeError) Error ¶
func (e *NoticeError) Error() string
type NoticeLevel ¶
type NoticeLevel int
const ( NoticeLevel_Info NoticeLevel = iota NoticeLevel_Warn NoticeLevel_Error )
type OAuthIdentifier ¶
type OAuthIdentifier int
const ( OAuthIdentifierEmail OAuthIdentifier = iota OAuthIdentifierName OAuthIdentifierNickName OAuthIdentifierUserID )
type OAuthInfo ¶
type OAuthInfo struct { OAuthProvider string `` /* 250-byte string literal not displayed */ OAuthUserID string `gorm:"index:uidx_users_oauth_provider_user_id,unique,where:o_auth_provider!='' and o_auth_user_id!='' and deleted_at is null"` // OAuthIdentifier is an externally-facing account identifier, such as an email address for a Google account. // it is used to find the user record on the first login OAuthIdentifier string `` /* 131-byte string literal not displayed */ OAuthAvatar string `gorm:"-"` }
func (*OAuthInfo) FindUserByOAuthIdentifier ¶
func (*OAuthInfo) FindUserByOAuthUserID ¶
func (*OAuthInfo) InitOAuthUserID ¶
type OAuthUser ¶
type OAuthUser interface { FindUserByOAuthUserID(db *gorm.DB, model interface{}, provider string, oid string) (user interface{}, err error) FindUserByOAuthIdentifier(db *gorm.DB, model interface{}, provider string, identifier string) (user interface{}, err error) // only update the o_auth_user_id when it's empty(null or ”) InitOAuthUserID(db *gorm.DB, model interface{}, provider string, identifier string, oid string) error SetAvatar(v string) GetAvatar() string }
type PrimaryFielder ¶
type PrimaryFielder interface {
PrimaryField() string
}
type RecaptchaConfig ¶
type SessionSecure ¶
type SessionSecure struct {
SessionSecure string `gorm:"size:32"`
}
func (*SessionSecure) GetSecure ¶
func (ss *SessionSecure) GetSecure() string
func (*SessionSecure) UpdateSecure ¶
func (ss *SessionSecure) UpdateSecure(db *gorm.DB, model interface{}, id string) error
type SessionSecureUserPasser ¶
type SessionSecureUserPasser interface { SessionSecurer UserPasser }
type SessionSecurer ¶
type TOTPConfig ¶
type TOTPConfig struct {
Issuer string
}
type UserClaims ¶
type UserPass ¶
type UserPass struct { Account string `gorm:"index:uidx_users_account,unique,where:account!='' and deleted_at is null"` Password string `gorm:"size:60"` // UnixNano string PassUpdatedAt string LoginRetryCount int Locked bool LockedAt *time.Time ResetPasswordToken string `gorm:"index:uidx_users_reset_password_token,unique,where:reset_password_token!=''"` ResetPasswordTokenCreatedAt *time.Time ResetPasswordTokenExpiredAt *time.Time TOTPSecret string IsTOTPSetup bool LastUsedTOTPCode string LastTOTPCodeUsedAt *time.Time }
func (*UserPass) ConsumeResetPasswordToken ¶
func (*UserPass) EncryptPassword ¶
func (up *UserPass) EncryptPassword()
func (*UserPass) GenerateResetPasswordToken ¶
func (*UserPass) GetAccountName ¶
func (*UserPass) GetIsTOTPSetup ¶
func (*UserPass) GetLastUsedTOTPCode ¶
func (*UserPass) GetLoginRetryCount ¶
func (*UserPass) GetPasswordUpdatedAt ¶
func (*UserPass) GetResetPasswordToken ¶
func (*UserPass) GetTOTPSecret ¶
func (*UserPass) IncreaseRetryCount ¶
func (*UserPass) IsPasswordCorrect ¶
func (*UserPass) SetIsTOTPSetup ¶
func (*UserPass) SetLastUsedTOTPCode ¶
func (*UserPass) SetPassword ¶
func (*UserPass) SetTOTPSecret ¶
type UserPasser ¶
type UserPasser interface { FindUser(db *gorm.DB, model interface{}, account string) (user interface{}, err error) EncryptPassword() IsPasswordCorrect(password string) bool IncreaseRetryCount(db *gorm.DB, model interface{}) error GenerateResetPasswordToken(db *gorm.DB, model interface{}) (token string, err error) ConsumeResetPasswordToken(db *gorm.DB, model interface{}) error GetAccountName() string GetPasswordUpdatedAt() string GetLoginRetryCount() int GetLocked() bool GetIsTOTPSetup() bool GetTOTPSecret() string GetLastUsedTOTPCode() (code string, usedAt *time.Time) GetResetPasswordToken() (token string, createdAt *time.Time, expired bool) SetPassword(db *gorm.DB, model interface{}, password string) error SetIsTOTPSetup(db *gorm.DB, model interface{}, v bool) error SetTOTPSecret(db *gorm.DB, model interface{}, key string) error SetLastUsedTOTPCode(db *gorm.DB, model interface{}, passcode string) error LockUser(db *gorm.DB, model interface{}) error UnlockUser(db *gorm.DB, model interface{}) error }
type ViewCommon ¶
type ViewCommon struct { WrapperClass string TitleClass string LabelClass string InputClass string ButtonClass string }
func (*ViewCommon) ErrNotice ¶
func (vc *ViewCommon) ErrNotice(msg string) HTMLComponent
func (*ViewCommon) ErrorBody ¶
func (vc *ViewCommon) ErrorBody(msg string) HTMLComponent
func (*ViewCommon) InfoNotice ¶
func (vc *ViewCommon) InfoNotice(msg string) HTMLComponent
func (*ViewCommon) Notice ¶
func (vc *ViewCommon) Notice(vh *ViewHelper, msgr *Messages, w http.ResponseWriter, r *http.Request) HTMLComponent
func (*ViewCommon) PasswordInputWithRevealFunction ¶
func (vc *ViewCommon) PasswordInputWithRevealFunction( name string, placeholder string, id string, val string, ) HTMLComponent
func (*ViewCommon) PasswordStrengthMeter ¶
func (vc *ViewCommon) PasswordStrengthMeter(inputID string) HTMLComponent
func (*ViewCommon) WarnNotice ¶
func (vc *ViewCommon) WarnNotice(msg string) HTMLComponent
type ViewHelper ¶
type ViewHelper struct {
// contains filtered or unexported fields
}
func (*ViewHelper) ChangePasswordURL ¶
func (vh *ViewHelper) ChangePasswordURL() string
func (*ViewHelper) FindUserByID ¶
func (vh *ViewHelper) FindUserByID(id string) (user interface{}, err error)
func (*ViewHelper) ForgetPasswordPageURL ¶
func (vh *ViewHelper) ForgetPasswordPageURL() string
func (*ViewHelper) GetFailCodeFlash ¶
func (vh *ViewHelper) GetFailCodeFlash(w http.ResponseWriter, r *http.Request) FailCode
func (*ViewHelper) GetFailFlashMessage ¶
func (vh *ViewHelper) GetFailFlashMessage(msgr *Messages, w http.ResponseWriter, r *http.Request) string
func (*ViewHelper) GetInfoCodeFlash ¶
func (vh *ViewHelper) GetInfoCodeFlash(w http.ResponseWriter, r *http.Request) InfoCode
func (*ViewHelper) GetInfoFlashMessage ¶
func (vh *ViewHelper) GetInfoFlashMessage(msgr *Messages, w http.ResponseWriter, r *http.Request) string
func (*ViewHelper) GetNoticeFlash ¶
func (vh *ViewHelper) GetNoticeFlash(w http.ResponseWriter, r *http.Request) *NoticeError
func (*ViewHelper) GetSecondsToRedoFlash ¶
func (vh *ViewHelper) GetSecondsToRedoFlash(w http.ResponseWriter, r *http.Request) int
func (*ViewHelper) GetWarnCodeFlash ¶
func (vh *ViewHelper) GetWarnCodeFlash(w http.ResponseWriter, r *http.Request) WarnCode
func (*ViewHelper) GetWarnFlashMessage ¶
func (vh *ViewHelper) GetWarnFlashMessage(msgr *Messages, w http.ResponseWriter, r *http.Request) string
func (*ViewHelper) GetWrongChangePasswordInputFlash ¶
func (vh *ViewHelper) GetWrongChangePasswordInputFlash(w http.ResponseWriter, r *http.Request) WrongChangePasswordInputFlash
func (*ViewHelper) GetWrongForgetPasswordInputFlash ¶
func (vh *ViewHelper) GetWrongForgetPasswordInputFlash(w http.ResponseWriter, r *http.Request) WrongForgetPasswordInputFlash
func (*ViewHelper) GetWrongLoginInputFlash ¶
func (vh *ViewHelper) GetWrongLoginInputFlash(w http.ResponseWriter, r *http.Request) WrongLoginInputFlash
func (*ViewHelper) GetWrongResetPasswordInputFlash ¶
func (vh *ViewHelper) GetWrongResetPasswordInputFlash(w http.ResponseWriter, r *http.Request) WrongResetPasswordInputFlash
func (*ViewHelper) I18n ¶
func (vh *ViewHelper) I18n() *i18n.Builder
func (*ViewHelper) NoForgetPasswordLink ¶
func (vh *ViewHelper) NoForgetPasswordLink() bool
func (*ViewHelper) OAuthBeginURL ¶
func (vh *ViewHelper) OAuthBeginURL() string
func (*ViewHelper) OAuthEnabled ¶
func (vh *ViewHelper) OAuthEnabled() bool
func (*ViewHelper) OAuthProviders ¶
func (vh *ViewHelper) OAuthProviders() []*Provider
func (*ViewHelper) PasswordLoginURL ¶
func (vh *ViewHelper) PasswordLoginURL() string
func (*ViewHelper) RecaptchaEnabled ¶
func (vh *ViewHelper) RecaptchaEnabled() bool
func (*ViewHelper) RecaptchaSiteKey ¶
func (vh *ViewHelper) RecaptchaSiteKey() string
func (*ViewHelper) ResetPasswordURL ¶
func (vh *ViewHelper) ResetPasswordURL() string
func (*ViewHelper) SendResetPasswordLinkURL ¶
func (vh *ViewHelper) SendResetPasswordLinkURL() string
func (*ViewHelper) TOTPEnabled ¶
func (vh *ViewHelper) TOTPEnabled() bool
func (*ViewHelper) TOTPIssuer ¶
func (vh *ViewHelper) TOTPIssuer() string
func (*ViewHelper) UserPassEnabled ¶
func (vh *ViewHelper) UserPassEnabled() bool
func (*ViewHelper) ValidateTOTPURL ¶
func (vh *ViewHelper) ValidateTOTPURL() string