Documentation ¶
Index ¶
- func IsAuthorized(user UserInfo, permission string) bool
- func NewSessionId() string
- type Authenticator
- func (a *Authenticator) ChangePassword(ctx context.Context, userInfo UserInfo, oldPassword, password string) ChangePasswordResult
- func (a *Authenticator) CheckLogin(ctx context.Context, username, password string) ([]UserInfo, error)
- func (a *Authenticator) CheckSession(ctx context.Context, sessionid string) SessionInfo
- func (a *Authenticator) GetUser(ctx context.Context, username string) ([]UserInfo, error)
- func (a *Authenticator) Logout(ctx context.Context, sessionid string)
- func (a *Authenticator) RequestPasswordReset(ctx context.Context, email string) RequestResetResult
- func (a *Authenticator) ResetPassword(ctx context.Context, token, password string) bool
- func (a *Authenticator) SaveSession(ctx context.Context, sessionid string, userInfo UserInfo, authenticated int) SessionInfo
- func (a *Authenticator) UpdateSession(ctx context.Context, sessionid string, userInfo UserInfo, authenticated int) SessionInfo
- type ChangePasswordResult
- type RequestResetResult
- type SessionInfo
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAuthorized ¶
Generate a new session id after login
Types ¶
type Authenticator ¶ added in v0.0.15
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator holds stateful items needed for user authentication.
func NewAuthenticator ¶ added in v0.0.17
func NewAuthenticator(ctx context.Context) (*Authenticator, error)
NewAuthenticator creates but does not initialize an Authenticator object.
Params:
isProtected - set this to true if only the site is password protected
func (*Authenticator) ChangePassword ¶ added in v0.0.17
func (a *Authenticator) ChangePassword(ctx context.Context, userInfo UserInfo, oldPassword, password string) ChangePasswordResult
ChangePassword enables the user to change passwords.
func (*Authenticator) CheckLogin ¶ added in v0.0.17
func (a *Authenticator) CheckLogin(ctx context.Context, username, password string) ([]UserInfo, error)
CheckLogin checks the password when the user logs in.
func (*Authenticator) CheckSession ¶ added in v0.0.17
func (a *Authenticator) CheckSession(ctx context.Context, sessionid string) SessionInfo
CheckSession checks the session when the user requests a page.
func (*Authenticator) Logout ¶ added in v0.0.17
func (a *Authenticator) Logout(ctx context.Context, sessionid string)
Logout logs the user out of the current session.
func (*Authenticator) RequestPasswordReset ¶ added in v0.0.17
func (a *Authenticator) RequestPasswordReset(ctx context.Context, email string) RequestResetResult
RequestPasswordReset requests a password reset, to be sent by email.
func (*Authenticator) ResetPassword ¶ added in v0.0.17
func (a *Authenticator) ResetPassword(ctx context.Context, token, password string) bool
ResetPassword resets a password.
func (*Authenticator) SaveSession ¶ added in v0.0.17
func (a *Authenticator) SaveSession(ctx context.Context, sessionid string, userInfo UserInfo, authenticated int) SessionInfo
SaveSession saves an authenticated session to the database
func (*Authenticator) UpdateSession ¶ added in v0.0.17
func (a *Authenticator) UpdateSession(ctx context.Context, sessionid string, userInfo UserInfo, authenticated int) SessionInfo
UpdateSession logs a user in when they already have an unauthenticated session.
type ChangePasswordResult ¶
func OldPasswordDoesNotMatch ¶
func OldPasswordDoesNotMatch() ChangePasswordResult
Old password does not match
type RequestResetResult ¶
type SessionInfo ¶
func InvalidSession ¶
func InvalidSession() SessionInfo
InvalidSession creates an empty session struct.