Documentation
¶
Index ¶
- Constants
- Variables
- func AutoMigrateSession(db *gorm.DB, tablePrefix string) error
- func New(pb *presets.Builder) *login.Builder
- type CustomizeCompoFunc
- type LoginSession
- type Messages
- 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) 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) ExtendSession(r *http.Request, uid string, oldToken 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) Secret(v string) *SessionBuilder
- func (b *SessionBuilder) TablePrefix(prefix string) *SessionBuilder
- 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 (
I18nAdminLoginKey i18n.ModuleKey = "I18nAdminLoginKey"
)
View Source
const (
LoginTokenHashLen = 8 // The hash string length of the token stored in the DB.
)
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",
SessionTableHeaderIPAddress: "IP Address",
SessionTableHeaderStatus: "Status",
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.",
UnreadMessagesTemplate: "{n} unread notes",
ViewLoginSessions: "View login sessions",
Logout: "Logout",
Available: "Available",
Unavailable: "Unavailable",
SuccessfullyRename: "Successfully renamed",
}
View Source
var Messages_ja_JP = &Messages{
SessionTableHeaderTime: "時間",
SessionTableHeaderDevice: "デバイス",
SessionTableHeaderIPAddress: "IPアドレス",
SessionTableHeaderStatus: "ステータス",
SessionsDialogTitle: "ログインセッション",
SessionStatusExpired: "期限切れ",
SessionStatusActive: "有効",
SessionStatusCurrent: "現在のセッション",
HideIPAddressTips: "セキュリティ保護のため表示できません",
ExpireOtherSessions: "他のすべてのセッションからサインアウトする",
SuccessfullyExpiredOtherSessions: "他のすべてのセッションは正常にサインアウトされました。",
UnreadMessagesTemplate: "{n} 件の未読",
ViewLoginSessions: "ログインセッションを表示",
Logout: "ログアウト",
Available: "利用可能",
Unavailable: "利用不可",
SuccessfullyRename: "名前が変更されました",
}
View Source
var Messages_zh_CN = &Messages{
SessionTableHeaderTime: "时间",
SessionTableHeaderDevice: "设备",
SessionTableHeaderIPAddress: "IP地址",
SessionTableHeaderStatus: "状态",
SessionsDialogTitle: "登录会话",
SessionStatusExpired: "已过期",
SessionStatusActive: "有效",
SessionStatusCurrent: "当前会话",
HideIPAddressTips: "由于安全原因,隐藏",
ExpireOtherSessions: "登出所有其他会话",
SuccessfullyExpiredOtherSessions: "所有其他会话已成功登出。",
UnreadMessagesTemplate: "未读 {n} 条",
ViewLoginSessions: "查看登录会话",
Logout: "登出",
Available: "可用",
Unavailable: "不可用",
SuccessfullyRename: "成功重命名",
}
View Source
var NopCustomizeCompoFunc = func(ctx context.Context, profileCompo *ProfileCompo, current h.HTMLComponent) (h.HTMLComponent, error) { return current, nil }
Functions ¶
func AutoMigrateSession ¶ added in v3.0.3
Types ¶
type CustomizeCompoFunc ¶ added in v3.0.4
type CustomizeCompoFunc func(ctx context.Context, profileCompo *ProfileCompo, current h.HTMLComponent) (h.HTMLComponent, error)
type LoginSession ¶ added in v3.0.3
type Messages ¶ added in v3.0.3
type Messages struct {
SessionTableHeaderTime string
SessionTableHeaderDevice string
SessionTableHeaderIPAddress string
SessionTableHeaderStatus string
SessionsDialogTitle string
SessionStatusExpired string
SessionStatusActive string
SessionStatusCurrent string
HideIPAddressTips string
ExpireOtherSessions string
SuccessfullyExpiredOtherSessions string
UnreadMessagesTemplate string
ViewLoginSessions string
Logout string
Available string
SuccessfullyRename string
}
func (*Messages) UnreadMessages ¶ added in v3.0.3
type Profile ¶ added in v3.0.3
type Profile struct {
ID string
Name string
Avatar string
Roles []string
Status string
Fields []*ProfileField
NotifCounts []*activity.NoteCount
}
func (*Profile) GetFirstRole ¶ added in v3.0.3
type ProfileBuilder ¶ added in v3.0.3
type ProfileBuilder struct {
// contains filtered or unexported fields
}
func NewProfileBuilder ¶ added in v3.0.3
func NewProfileBuilder( currentProfileFunc func(ctx context.Context) (*Profile, error), renameCallback RenameCallback, ) *ProfileBuilder
func (*ProfileBuilder) CustomizeButtons ¶ added in v3.0.3
func (b *ProfileBuilder) CustomizeButtons(v func(ctx context.Context, buttons ...h.HTMLComponent) ([]h.HTMLComponent, error)) *ProfileBuilder
func (*ProfileBuilder) DisableNotification ¶ added in v3.0.3
func (b *ProfileBuilder) DisableNotification(v bool) *ProfileBuilder
func (*ProfileBuilder) Install ¶ added in v3.0.3
func (b *ProfileBuilder) Install(pb *presets.Builder) error
func (*ProfileBuilder) LogoutURL ¶ added in v3.0.3
func (b *ProfileBuilder) LogoutURL(s string) *ProfileBuilder
func (*ProfileBuilder) NewCompo ¶ added in v3.0.3
func (b *ProfileBuilder) NewCompo(evCtx *web.EventContext, idSuffix string) h.HTMLComponent
func (*ProfileBuilder) PrependCompos ¶ added in v3.0.3
func (b *ProfileBuilder) PrependCompos(f func(ctx context.Context, profileCompo *ProfileCompo) ([]h.HTMLComponent, error)) *ProfileBuilder
func (*ProfileBuilder) SessionBuilder ¶ added in v3.0.3
func (b *ProfileBuilder) SessionBuilder(lsb *SessionBuilder) *ProfileBuilder
func (*ProfileBuilder) WrapPrependCompo ¶ added in v3.0.4
func (b *ProfileBuilder) WrapPrependCompo(w func(in CustomizeCompoFunc) CustomizeCompoFunc) *ProfileBuilder
func (*ProfileBuilder) WrapRenameCallback ¶ added in v3.0.4
func (b *ProfileBuilder) WrapRenameCallback(w func(in RenameCallback) RenameCallback) *ProfileBuilder
func (*ProfileBuilder) WrapSubtitleCompo ¶ added in v3.0.4
func (b *ProfileBuilder) WrapSubtitleCompo(w func(in CustomizeCompoFunc) CustomizeCompoFunc) *ProfileBuilder
type ProfileCompo ¶ added in v3.0.3
type ProfileCompo struct {
ID string `json:"id"`
// contains filtered or unexported fields
}
func ProfileCompoFromContext ¶ added in v3.0.3
func ProfileCompoFromContext(ctx context.Context) *ProfileCompo
func ProfileCompoFromEventContext ¶ added in v3.0.3
func ProfileCompoFromEventContext(evCtx *web.EventContext) *ProfileCompo
func (*ProfileCompo) CompoID ¶ added in v3.0.3
func (c *ProfileCompo) CompoID() string
func (*ProfileCompo) MarshalHTML ¶ added in v3.0.3
func (c *ProfileCompo) MarshalHTML(ctx context.Context) ([]byte, error)
func (*ProfileCompo) MustGetEventContext ¶ added in v3.0.3
func (c *ProfileCompo) MustGetEventContext(ctx context.Context) (*web.EventContext, *Messages)
func (*ProfileCompo) Rename ¶ added in v3.0.3
func (c *ProfileCompo) Rename(ctx context.Context, req RenameRequest) (r web.EventResponse, _ error)
type ProfileField ¶ added in v3.0.3
type RenameCallback ¶ added in v3.0.4
type RenameRequest ¶ added in v3.0.3
type RenameRequest struct {
Name string `json:"name"`
}
type SessionBuilder ¶ added in v3.0.3
type SessionBuilder struct {
// contains filtered or unexported fields
}
func NewSessionBuilder ¶ added in v3.0.3
func NewSessionBuilder(lb *login.Builder, db *gorm.DB) *SessionBuilder
func (*SessionBuilder) Activity ¶ added in v3.0.3
func (b *SessionBuilder) Activity(amb *activity.ModelBuilder) *SessionBuilder
func (*SessionBuilder) AutoMigrate ¶ added in v3.0.3
func (b *SessionBuilder) AutoMigrate() (r *SessionBuilder)
func (*SessionBuilder) CreateSession ¶ added in v3.0.3
func (b *SessionBuilder) CreateSession(r *http.Request, uid string) error
func (*SessionBuilder) ExpireAllSessions ¶ added in v3.0.3
func (b *SessionBuilder) ExpireAllSessions(uid string) error
func (*SessionBuilder) ExpireCurrentSession ¶ added in v3.0.3
func (b *SessionBuilder) ExpireCurrentSession(r *http.Request, uid string) error
func (*SessionBuilder) ExpireOtherSessions ¶ added in v3.0.3
func (b *SessionBuilder) ExpireOtherSessions(r *http.Request, uid string) error
func (*SessionBuilder) ExtendSession ¶ added in v3.0.3
func (*SessionBuilder) GetLoginBuilder ¶ added in v3.0.3
func (b *SessionBuilder) GetLoginBuilder() *login.Builder
func (*SessionBuilder) Install ¶ added in v3.0.3
func (b *SessionBuilder) Install(pb *presets.Builder) error
func (*SessionBuilder) IsPublicUser ¶ added in v3.0.3
func (b *SessionBuilder) IsPublicUser(f func(user any) bool) *SessionBuilder
func (*SessionBuilder) IsSessionValid ¶ added in v3.0.3
func (*SessionBuilder) Middleware ¶ added in v3.0.3
func (b *SessionBuilder) Middleware(cfgs ...login.MiddlewareConfig) func(next http.Handler) http.Handler
func (*SessionBuilder) Mount ¶ added in v3.0.3
func (b *SessionBuilder) Mount(mux *http.ServeMux)
func (*SessionBuilder) MountAPI ¶ added in v3.0.3
func (b *SessionBuilder) MountAPI(mux *http.ServeMux)
func (*SessionBuilder) OpenSessionsDialog ¶ added in v3.0.3
func (b *SessionBuilder) OpenSessionsDialog() string
func (*SessionBuilder) Secret ¶ added in v3.0.3
func (b *SessionBuilder) Secret(v string) *SessionBuilder
func (*SessionBuilder) TablePrefix ¶ added in v3.0.3
func (b *SessionBuilder) TablePrefix(prefix string) *SessionBuilder
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.