Documentation
¶
Index ¶
- Constants
- Variables
- func AutoMigrateSession(db *gorm.DB, tablePrefix string) error
- func New(pb *presets.Builder) *login.Builder
- func NewAdvancedLoginPage(...) func(vh *login.ViewHelper, pb *presets.Builder) web.PageFunc
- func ZxcvbnLogicComponent() HTMLComponent
- type AdvancedLoginPageConfig
- type CustomizeCompoFunc
- type LoginSession
- type Messages
- type OAuthProviderDisplay
- type Profile
- type ProfileBuilder
- func (b *ProfileBuilder) CustomizeButtons(...) *ProfileBuilder
- func (b *ProfileBuilder) DisableNotification(v bool) *ProfileBuilder
- func (b *ProfileBuilder) Install(pb *presets.Builder) error
- func (b *ProfileBuilder) LogoutURL(s string) *ProfileBuilder
- func (b *ProfileBuilder) NewCompo(evCtx *web.EventContext, idSuffix string) h.HTMLComponent
- func (b *ProfileBuilder) PrependCompos(...) *ProfileBuilder
- func (b *ProfileBuilder) SessionBuilder(lsb *SessionBuilder) *ProfileBuilder
- func (b *ProfileBuilder) WrapPrependCompo(w func(in CustomizeCompoFunc) CustomizeCompoFunc) *ProfileBuilder
- func (b *ProfileBuilder) WrapRenameCallback(w func(in RenameCallback) RenameCallback) *ProfileBuilder
- func (b *ProfileBuilder) WrapSubtitleCompo(w func(in CustomizeCompoFunc) CustomizeCompoFunc) *ProfileBuilder
- type ProfileCompo
- func (c *ProfileCompo) CompoID() string
- func (c *ProfileCompo) MarshalHTML(ctx context.Context) ([]byte, error)
- func (c *ProfileCompo) MustGetEventContext(ctx context.Context) (*web.EventContext, *Messages)
- func (c *ProfileCompo) Rename(ctx context.Context, req RenameRequest) (r web.EventResponse, _ error)
- type ProfileField
- type RenameCallback
- type RenameRequest
- type SessionBuilder
- func (b *SessionBuilder) Activity(amb *activity.ModelBuilder) *SessionBuilder
- func (b *SessionBuilder) AutoMigrate() (r *SessionBuilder)
- func (b *SessionBuilder) CreateSession(r *http.Request, uid string) error
- func (b *SessionBuilder) DisableIPCheck(disabled bool) *SessionBuilder
- func (b *SessionBuilder) ExpireAllSessions(uid string) error
- func (b *SessionBuilder) ExpireCurrentSession(r *http.Request, uid string) error
- func (b *SessionBuilder) ExpireOtherSessions(r *http.Request, uid string) error
- func (b *SessionBuilder) ExpireSession(uid, tokenHash string) error
- func (b *SessionBuilder) ExtendSession(r *http.Request, uid string, oldToken, newToken string) error
- func (b *SessionBuilder) GetLoginBuilder() *login.Builder
- func (b *SessionBuilder) Install(pb *presets.Builder) error
- func (b *SessionBuilder) IsPublicUser(f func(user any) bool) *SessionBuilder
- func (b *SessionBuilder) IsSessionValid(r *http.Request, uid string) (valid bool, err error)
- func (b *SessionBuilder) Middleware(cfgs ...login.MiddlewareConfig) func(next http.Handler) http.Handler
- func (b *SessionBuilder) Mount(mux *http.ServeMux)
- func (b *SessionBuilder) MountAPI(mux *http.ServeMux)
- func (b *SessionBuilder) OpenSessionsDialog() string
- func (b *SessionBuilder) ParseIPFunc(f func(ctx context.Context, lang language.Tag, addr string) (string, error)) *SessionBuilder
- func (b *SessionBuilder) Secret(v string) *SessionBuilder
- func (b *SessionBuilder) TablePrefix(prefix string) *SessionBuilder
- func (b *SessionBuilder) UpdateSessionLastActivedAt(r *http.Request, uid string) error
- type ViewCommon
- func (vc *ViewCommon) ErrNotice(msg string) HTMLComponent
- func (vc *ViewCommon) ErrorBody(msg string) HTMLComponent
- func (vc *ViewCommon) FormSubmitBtn(label string) *VBtnBuilder
- func (vc *ViewCommon) InfoNotice(msg string) HTMLComponent
- func (vc *ViewCommon) InjectRecaptchaAssets(ctx *web.EventContext, formID string, tokenFieldID string)
- func (vc *ViewCommon) InjectZxcvbn(ctx *web.EventContext)
- func (vc *ViewCommon) Input(id string, placeholder string, val string) *vx.VXFieldBuilder
- func (vc *ViewCommon) Notice(vh *login.ViewHelper, msgr *login.Messages, w http.ResponseWriter, ...) HTMLComponent
- func (vc *ViewCommon) PasswordInput(id string, placeholder string, val string, canReveal bool) *vx.VXFieldBuilder
- func (vc *ViewCommon) PasswordInputWithStrengthMeter(in *vx.VXFieldBuilder, id string, val string) HTMLComponent
- func (vc *ViewCommon) WarnNotice(msg string) HTMLComponent
Constants ¶
View Source
const ( LoginTokenHashLen = 8 // The hash string length of the token stored in the DB. GracePeriodAfterExtend = 1 * time.Minute )
View Source
const (
I18nAdminLoginKey i18n.ModuleKey = "I18nAdminLoginKey"
)
View Source
const (
OpenChangePasswordDialogEvent = "login_openChangePasswordDialog"
)
Variables ¶
View Source
var DefaultViewCommon = &ViewCommon{
WrapperClass: "d-flex pt-16 flex-column mx-auto",
WrapperStyle: "max-width: 28rem;",
TitleClass: "text-h5 mb-6 font-weight-bold",
LabelClass: "d-block mb-1 grey--text text--darken-2 text-sm-body-2",
}
View Source
var Messages_en_US = &Messages{
SessionTableHeaderTime: "Time",
SessionTableHeaderDevice: "Device",
SessionTableHeaderLocation: "Location",
SessionTableHeaderIPAddress: "IP Address",
SessionTableHeaderStatus: "Status",
SessionTableHeaderLastActivedAt: "Last Active Time",
SessionTableHeaderAction: "Action",
SessionsDialogTitle: "Login Sessions",
SessionStatusExpired: "Expired",
SessionStatusActive: "Active",
SessionStatusCurrent: "Current Session",
HideIPAddressTips: "Invisible due to security concerns",
ExpireOtherSessions: "Sign out all other sessions",
SuccessfullyExpiredOtherSessions: "All other sessions have successfully been signed out.",
SuccessfullyExpiredSessions: "Session has successfully been signed out.",
UnreadMessagesTemplate: "{n} unread notes",
ViewLoginSessions: "View login sessions",
Logout: "Logout",
Available: "Available",
Unavailable: "Unavailable",
SuccessfullyRename: "Successfully renamed",
LocationUnknown: "Unknown",
LoginWelcomeLabel: "Welcome",
LoginTitleLabel: "Qor Admin System",
LoginAccountLabel: "Email",
LoginAccountPlaceholder: "Please enter your email",
LoginPasswordLabel: "Password",
LoginPasswordPlaceholder: "Please enter your password",
LoginSignInButtonLabel: "Sign in",
LoginForgetPasswordLabel: "Forget your password?",
LoginQor5DescriptionLabel: "Enterprise Systems, Startup Speed",
LoginProviderGoogleText: "Sign in with Google",
LoginProviderMicrosoftText: "Sign in with Microsoft",
LoginProviderGithubText: "Sign in with Github",
}
View Source
var Messages_ja_JP = &Messages{
SessionTableHeaderTime: "時間",
SessionTableHeaderDevice: "デバイス",
SessionTableHeaderLocation: "位置",
SessionTableHeaderIPAddress: "IPアドレス",
SessionTableHeaderStatus: "ステータス",
SessionTableHeaderLastActivedAt: "最終アクティブ",
SessionTableHeaderAction: "アクション",
SessionsDialogTitle: "ログインセッション",
SessionStatusExpired: "期限切れ",
SessionStatusActive: "有効",
SessionStatusCurrent: "現在のセッション",
HideIPAddressTips: "セキュリティ保護のため表示できません",
ExpireOtherSessions: "他のすべてのセッションからサインアウトする",
SuccessfullyExpiredOtherSessions: "他のすべてのセッションは正常にサインアウトされました。",
SuccessfullyExpiredSessions: "セッションは正常にサインアウトされました。",
UnreadMessagesTemplate: "{n} 件の未読",
ViewLoginSessions: "ログインセッションを表示",
Logout: "ログアウト",
Available: "利用可能",
Unavailable: "利用不可",
SuccessfullyRename: "名前が変更されました",
LocationUnknown: "不明",
LoginWelcomeLabel: "ようこそ",
LoginTitleLabel: "Qor 管理システム",
LoginAccountLabel: "メールアドレス",
LoginAccountPlaceholder: "メールアドレスを入力してください",
LoginPasswordLabel: "パスワード",
LoginPasswordPlaceholder: "パスワードを入力してください",
LoginSignInButtonLabel: "サインイン",
LoginForgetPasswordLabel: "パスワードをお忘れですか?",
LoginQor5DescriptionLabel: "エンタープライズシステム、スタートアップスピード",
LoginProviderGoogleText: "Google でログイン",
LoginProviderMicrosoftText: "Microsoft でログイン",
LoginProviderGithubText: "Github でログイン",
}
View Source
var Messages_zh_CN = &Messages{
SessionTableHeaderTime: "时间",
SessionTableHeaderDevice: "设备",
SessionTableHeaderLocation: "位置",
SessionTableHeaderIPAddress: "IP地址",
SessionTableHeaderStatus: "状态",
SessionTableHeaderLastActivedAt: "最后活跃时间",
SessionTableHeaderAction: "操作",
SessionsDialogTitle: "登录会话",
SessionStatusExpired: "已过期",
SessionStatusActive: "有效",
SessionStatusCurrent: "当前会话",
HideIPAddressTips: "由于安全原因,隐藏",
ExpireOtherSessions: "登出所有其他会话",
SuccessfullyExpiredOtherSessions: "所有其他会话已成功登出。",
SuccessfullyExpiredSessions: "会话已成功登出。",
UnreadMessagesTemplate: "未读 {n} 条",
ViewLoginSessions: "查看登录会话",
Logout: "登出",
Available: "可用",
Unavailable: "不可用",
SuccessfullyRename: "成功重命名",
LocationUnknown: "未知",
LoginWelcomeLabel: "欢迎",
LoginTitleLabel: "Qor 管理系统",
LoginAccountLabel: "邮箱",
LoginAccountPlaceholder: "请输入您的邮箱",
LoginPasswordLabel: "密码",
LoginPasswordPlaceholder: "请输入您的密码",
LoginSignInButtonLabel: "登录",
LoginForgetPasswordLabel: "忘记密码?",
LoginQor5DescriptionLabel: "企业级系统,创业速度",
LoginProviderGoogleText: "使用 Google 登录",
LoginProviderMicrosoftText: "使用 Microsoft 登录",
LoginProviderGithubText: "使用 Github 登录",
}
View Source
var NopCustomizeCompoFunc = func(ctx context.Context, profileCompo *ProfileCompo, current h.HTMLComponent) (h.HTMLComponent, error) { return current, nil }
Functions ¶
func NewAdvancedLoginPage ¶
func NewAdvancedLoginPage(customize func(ctx *web.EventContext, config *AdvancedLoginPageConfig) (*AdvancedLoginPageConfig, error)) func(vh *login.ViewHelper, pb *presets.Builder) web.PageFunc
func ZxcvbnLogicComponent ¶
func ZxcvbnLogicComponent() HTMLComponent
Types ¶
type AdvancedLoginPageConfig ¶
type AdvancedLoginPageConfig struct {
WelcomeLabel string
TitleLabel string
AccountLabel string
AccountPlaceholder string
PasswordLabel string
PasswordPlaceholder string
SignInButtonLabel string
ForgetPasswordLabel string
OAuthProviderDisplay func(provider *login.Provider) OAuthProviderDisplay
BrandLogo HTMLComponent
LeftImage HTMLComponent
Qor5DescriptionLabel string
RightMaxWidth string
PageTitle string
}
type CustomizeCompoFunc ¶
type CustomizeCompoFunc func(ctx context.Context, profileCompo *ProfileCompo, current h.HTMLComponent) (h.HTMLComponent, error)
type LoginSession ¶
type LoginSession struct {
gorm.Model
UserID string `gorm:"size:36;index;not null"`
Device string `gorm:"size:128;not null"`
IP string `gorm:"size:128;not null"`
TokenHash string `gorm:"size:36;index;not null"`
ExpiredAt time.Time `gorm:"not null"`
ExtendedAt time.Time `gorm:"index"`
LastTokenHash string `gorm:"size:36;default:'';index"`
LastActivedAt time.Time
}
type Messages ¶
type Messages struct {
SessionTableHeaderTime string
SessionTableHeaderDevice string
SessionTableHeaderLocation string
SessionTableHeaderIPAddress string
SessionTableHeaderStatus string
SessionTableHeaderLastActivedAt string
SessionTableHeaderAction string
SessionsDialogTitle string
SessionStatusExpired string
SessionStatusActive string
SessionStatusCurrent string
HideIPAddressTips string
ExpireOtherSessions string
SuccessfullyExpiredOtherSessions string
SuccessfullyExpiredSessions string
UnreadMessagesTemplate string
ViewLoginSessions string
Logout string
Available string
SuccessfullyRename string
LocationUnknown string
LoginWelcomeLabel string
LoginTitleLabel string
LoginAccountLabel string
LoginAccountPlaceholder string
LoginPasswordLabel string
LoginPasswordPlaceholder string
LoginSignInButtonLabel string
LoginForgetPasswordLabel string
LoginQor5DescriptionLabel string
LoginProviderGoogleText string
LoginProviderMicrosoftText string
LoginProviderGithubText string
}
func (*Messages) UnreadMessages ¶
type OAuthProviderDisplay ¶
type OAuthProviderDisplay struct {
Logo HTMLComponent
Text string
}
type Profile ¶
type Profile struct {
ID string
Name string
Avatar string
Roles []string
Status string
Fields []*ProfileField
NotifCounts []*activity.NoteCount
}
func (*Profile) GetFirstRole ¶
type ProfileBuilder ¶
type ProfileBuilder struct {
// contains filtered or unexported fields
}
func NewProfileBuilder ¶
func NewProfileBuilder( currentProfileFunc func(ctx context.Context) (*Profile, error), renameCallback RenameCallback, ) *ProfileBuilder
func (*ProfileBuilder) CustomizeButtons ¶
func (b *ProfileBuilder) CustomizeButtons(v func(ctx context.Context, buttons ...h.HTMLComponent) ([]h.HTMLComponent, error)) *ProfileBuilder
func (*ProfileBuilder) DisableNotification ¶
func (b *ProfileBuilder) DisableNotification(v bool) *ProfileBuilder
func (*ProfileBuilder) LogoutURL ¶
func (b *ProfileBuilder) LogoutURL(s string) *ProfileBuilder
func (*ProfileBuilder) NewCompo ¶
func (b *ProfileBuilder) NewCompo(evCtx *web.EventContext, idSuffix string) h.HTMLComponent
func (*ProfileBuilder) PrependCompos ¶
func (b *ProfileBuilder) PrependCompos(f func(ctx context.Context, profileCompo *ProfileCompo) ([]h.HTMLComponent, error)) *ProfileBuilder
func (*ProfileBuilder) SessionBuilder ¶
func (b *ProfileBuilder) SessionBuilder(lsb *SessionBuilder) *ProfileBuilder
func (*ProfileBuilder) WrapPrependCompo ¶
func (b *ProfileBuilder) WrapPrependCompo(w func(in CustomizeCompoFunc) CustomizeCompoFunc) *ProfileBuilder
func (*ProfileBuilder) WrapRenameCallback ¶
func (b *ProfileBuilder) WrapRenameCallback(w func(in RenameCallback) RenameCallback) *ProfileBuilder
func (*ProfileBuilder) WrapSubtitleCompo ¶
func (b *ProfileBuilder) WrapSubtitleCompo(w func(in CustomizeCompoFunc) CustomizeCompoFunc) *ProfileBuilder
type ProfileCompo ¶
type ProfileCompo struct {
ID string `json:"id"`
// contains filtered or unexported fields
}
func ProfileCompoFromContext ¶
func ProfileCompoFromContext(ctx context.Context) *ProfileCompo
func ProfileCompoFromEventContext ¶
func ProfileCompoFromEventContext(evCtx *web.EventContext) *ProfileCompo
func (*ProfileCompo) CompoID ¶
func (c *ProfileCompo) CompoID() string
func (*ProfileCompo) MarshalHTML ¶
func (c *ProfileCompo) MarshalHTML(ctx context.Context) ([]byte, error)
func (*ProfileCompo) MustGetEventContext ¶
func (c *ProfileCompo) MustGetEventContext(ctx context.Context) (*web.EventContext, *Messages)
func (*ProfileCompo) Rename ¶
func (c *ProfileCompo) Rename(ctx context.Context, req RenameRequest) (r web.EventResponse, _ error)
type ProfileField ¶
type RenameRequest ¶
type RenameRequest struct {
Name string `json:"name"`
}
type SessionBuilder ¶
type SessionBuilder struct {
// contains filtered or unexported fields
}
func NewSessionBuilder ¶
func NewSessionBuilder(lb *login.Builder, db *gorm.DB) *SessionBuilder
func (*SessionBuilder) Activity ¶
func (b *SessionBuilder) Activity(amb *activity.ModelBuilder) *SessionBuilder
func (*SessionBuilder) AutoMigrate ¶
func (b *SessionBuilder) AutoMigrate() (r *SessionBuilder)
func (*SessionBuilder) CreateSession ¶
func (b *SessionBuilder) CreateSession(r *http.Request, uid string) error
func (*SessionBuilder) DisableIPCheck ¶
func (b *SessionBuilder) DisableIPCheck(disabled bool) *SessionBuilder
func (*SessionBuilder) ExpireAllSessions ¶
func (b *SessionBuilder) ExpireAllSessions(uid string) error
func (*SessionBuilder) ExpireCurrentSession ¶
func (b *SessionBuilder) ExpireCurrentSession(r *http.Request, uid string) error
func (*SessionBuilder) ExpireOtherSessions ¶
func (b *SessionBuilder) ExpireOtherSessions(r *http.Request, uid string) error
func (*SessionBuilder) ExpireSession ¶
func (b *SessionBuilder) ExpireSession(uid, tokenHash string) error
func (*SessionBuilder) ExtendSession ¶
func (*SessionBuilder) GetLoginBuilder ¶
func (b *SessionBuilder) GetLoginBuilder() *login.Builder
func (*SessionBuilder) IsPublicUser ¶
func (b *SessionBuilder) IsPublicUser(f func(user any) bool) *SessionBuilder
func (*SessionBuilder) IsSessionValid ¶
func (*SessionBuilder) Middleware ¶
func (b *SessionBuilder) Middleware(cfgs ...login.MiddlewareConfig) func(next http.Handler) http.Handler
func (*SessionBuilder) Mount ¶
func (b *SessionBuilder) Mount(mux *http.ServeMux)
func (*SessionBuilder) MountAPI ¶
func (b *SessionBuilder) MountAPI(mux *http.ServeMux)
func (*SessionBuilder) OpenSessionsDialog ¶
func (b *SessionBuilder) OpenSessionsDialog() string
func (*SessionBuilder) ParseIPFunc ¶
func (b *SessionBuilder) ParseIPFunc(f func(ctx context.Context, lang language.Tag, addr string) (string, error)) *SessionBuilder
func (*SessionBuilder) Secret ¶
func (b *SessionBuilder) Secret(v string) *SessionBuilder
func (*SessionBuilder) TablePrefix ¶
func (b *SessionBuilder) TablePrefix(prefix string) *SessionBuilder
func (*SessionBuilder) UpdateSessionLastActivedAt ¶
func (b *SessionBuilder) UpdateSessionLastActivedAt(r *http.Request, uid string) error
type ViewCommon ¶
type ViewCommon struct {
WrapperClass string
WrapperStyle string
TitleClass string
LabelClass string
}
func (*ViewCommon) ErrNotice ¶
func (vc *ViewCommon) ErrNotice(msg string) HTMLComponent
func (*ViewCommon) ErrorBody ¶
func (vc *ViewCommon) ErrorBody(msg string) HTMLComponent
func (*ViewCommon) FormSubmitBtn ¶
func (vc *ViewCommon) FormSubmitBtn( label string, ) *VBtnBuilder
func (*ViewCommon) InfoNotice ¶
func (vc *ViewCommon) InfoNotice(msg string) HTMLComponent
func (*ViewCommon) InjectRecaptchaAssets ¶
func (vc *ViewCommon) InjectRecaptchaAssets(ctx *web.EventContext, formID string, tokenFieldID string)
requirements: - submit button
- add class `g-recaptcha`
- add attr `data-sitekey=<key>`
- add attr `data-callback=onSubmit`
- add token field like `Input("token").Id("token").Type("hidden")`
func (*ViewCommon) InjectZxcvbn ¶
func (vc *ViewCommon) InjectZxcvbn(ctx *web.EventContext)
func (*ViewCommon) Input ¶
func (vc *ViewCommon) Input( id string, placeholder string, val string, ) *vx.VXFieldBuilder
func (*ViewCommon) Notice ¶
func (vc *ViewCommon) Notice(vh *login.ViewHelper, msgr *login.Messages, w http.ResponseWriter, r *http.Request) HTMLComponent
func (*ViewCommon) PasswordInput ¶
func (vc *ViewCommon) PasswordInput( id string, placeholder string, val string, canReveal bool, ) *vx.VXFieldBuilder
func (*ViewCommon) PasswordInputWithStrengthMeter ¶
func (vc *ViewCommon) PasswordInputWithStrengthMeter(in *vx.VXFieldBuilder, id string, val string) HTMLComponent
need to import zxcvbn.js
func (*ViewCommon) WarnNotice ¶
func (vc *ViewCommon) WarnNotice(msg string) HTMLComponent
Source Files
¶
Click to show internal directories.
Click to hide internal directories.