Documentation ¶
Index ¶
- Constants
- func Init() (err error)
- func IsAuth(i interface{}) bool
- func Logout(s *sessions.Session)
- func NavigateToLoginPage(s *sessions.Session)
- func NavigateToRegisterPage(s *sessions.Session)
- func OffEndAuthenticatedSession(f func(s *sessions.Session))
- func OffNewAuthenticatedSession(f func(s *sessions.Session))
- func OffRemovedUser(f func(userID string))
- func OnEndAuthenticatedSession(f func(s *sessions.Session))
- func OnNewAuthenticatedSession(f func(s *sessions.Session))
- func OnRemovedUser(f func(userID string))
- func RegisterGroup(name string, description string) error
- func Release()
- func RemoveUser(id string) error
- func ShowChangePasswordDialog(s *sessions.Session, u *User, opts ...ChangePasswordDialogOpts) error
- type ChangePasswordDialogOpts
- type Group
- type Groups
- type User
- func (u *User) AddGroup(groups ...string)
- func (u *User) Commit() error
- func (u *User) Created() int64
- func (u *User) EMail() string
- func (u *User) Enabled() bool
- func (u *User) Groups() []string
- func (u *User) ID() string
- func (u *User) IsAdmin() bool
- func (u *User) IsInGroup(groups ...string) bool
- func (u *User) IsInGroups(groups []string) bool
- func (u *User) IsSysOp() bool
- func (u *User) LastLogin() int64
- func (u *User) LoginName() string
- func (u *User) Name() string
- func (u *User) SetEMail(email string)
- func (u *User) SetEnabled(enabled bool)
- func (u *User) SetLoginName(loginName string)
- func (u *User) SetName(name string)
- func (u *User) Update() error
- type Users
Constants ¶
const ( // Page Urls LoginPageUrl = "/login" RegisterPageUrl = "/register" )
const ( DBUserTable = "users" DBUserTableIndex = "LoginName" )
const ( // System operator (system administrator): full access to the system. GroupSysOp = "sysop" // Administrator: client of the application. Administration of the page content and some basic stuff... GroupAdmin = "admin" )
Variables ¶
This section is empty.
Functions ¶
func IsAuth ¶
func IsAuth(i interface{}) bool
IsAuth returns a boolean if the current session is authenticated by a user login. You can pass a session or context value to this method. If a context value is available, then always pass it instead of the session. This will improve the performance and won't retrieve a user value multiple times from the database during one template execution cycle.
func NavigateToLoginPage ¶
func NavigateToRegisterPage ¶
func OffEndAuthenticatedSession ¶
OffEndAuthenticatedSession removes the listener again
func OffNewAuthenticatedSession ¶
OffNewAuthenticatedSession removes the listener again
func OffRemovedUser ¶
func OffRemovedUser(f func(userID string))
OffRemovedUser removes the listener again
func OnEndAuthenticatedSession ¶
OnEndAuthenticatedSession sets the function which is triggered during each logout
func OnNewAuthenticatedSession ¶
OnNewAuthenticatedSession sets the function which is triggered during each new authenticated session
func OnRemovedUser ¶
func OnRemovedUser(f func(userID string))
OnRemovedUser sets the function which is triggered if a user is removed.
func RegisterGroup ¶
RegisterGroup registeres a group. It is suggested to only use lower characters.
func RemoveUser ¶
func ShowChangePasswordDialog ¶
func ShowChangePasswordDialog(s *sessions.Session, u *User, opts ...ChangePasswordDialogOpts) error
ShowChangePasswordDialog shows a change password dialog for the given user. One optional parameter can be passed, defining a callback name for the callback package. This callback is executed on success.
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) Description ¶
type User ¶
type User struct {
// contains filtered or unexported fields
}
func AddUser ¶
func AddUser(loginName string, name string, email string, password string, removeOnExpire bool, groups ...string) (*User, error)
AddUser adds a new user to the database. If removeOnExpire is true, the user will be removed automatically if not logged in once for the expire timeout.
func GetUser ¶
func GetUser(i interface{}) *User
GetUser returns the logged in user value if logged in. Otherwise nil is returned. This user value is not updated, if any user data changes! Call user.Update() to get the latest state. You can pass a session or context value to this method. If a context value is available, then always pass it instead of the session. This will improve the performance and won't retrieve a user value multiple times from the database during one template execution cycle. This method returns nil, if the user is not enabled.
func GetUserByID ¶
GetUserByID retreives the user with the ID from the database.
func GetUserByLoginName ¶
GetUserByLoginName retreives the user with the login name from the database.
func (*User) AddGroup ¶
AddGroup adds the user to the group. You have to call the commit method to make this persistent.
func (*User) IsInGroup ¶
IsInGroup returns true if the user is in one of the passed groups. True is returned if no groups are passed.
func (*User) IsInGroups ¶
IsInGroups accepts a slice instead of variadic arguments. This might be useful if called from templates directly.
func (*User) SetEMail ¶
SetEMail sets the user's e-mail. You have to call the commit method to make this persistent.
func (*User) SetEnabled ¶
SetEnabled activates or disables the user. You have to call the commit method to make this persistent.
func (*User) SetLoginName ¶
SetLoginName sets the user's login name. You have to call the commit method to make this persistent.