identity

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAuthorized

func IsAuthorized(user UserInfo, permission string) bool

Generate a new session id after login

func Logout

func Logout(sessionid string)

Log the user out of the current session

func NewSessionId

func NewSessionId() string

Generate a new session id after login

func ResetPassword

func ResetPassword(token, password string) bool

Reset a password

Types

type ChangePasswordResult

type ChangePasswordResult struct {
	OldPasswordValid bool
	ChangeSuccessful bool
	ShowNewForm      bool
}

func ChangePassword

func ChangePassword(userInfo UserInfo, oldPassword, password string) ChangePasswordResult

Log a user in when they already have an unauthenticated session

func OldPasswordDoesNotMatch

func OldPasswordDoesNotMatch() ChangePasswordResult

Old password does not match

type RequestResetResult

type RequestResetResult struct {
	EmailValid          bool
	RequestResetSuccess bool
	ShowNewForm         bool
	User                UserInfo
	Token               string
}

func RequestPasswordReset

func RequestPasswordReset(email string) RequestResetResult

Request a password reset, to be sent by email

type SessionInfo

type SessionInfo struct {
	Authenticated int
	Valid         bool
	User          UserInfo
}

func CheckSession

func CheckSession(sessionid string) SessionInfo

Check session when the user requests a page

func InvalidSession

func InvalidSession() SessionInfo

Empty session struct for an unauthenticated session

func SaveSession

func SaveSession(sessionid string, userInfo UserInfo, authenticated int) SessionInfo

Save an authenticated session to the database

func UpdateSession

func UpdateSession(sessionid string, userInfo UserInfo, authenticated int) SessionInfo

Log a user in when they already have an unauthenticated session

type UserInfo

type UserInfo struct {
	UserID                          int
	UserName, Email, FullName, Role string
}

func CheckLogin

func CheckLogin(username, password string) ([]UserInfo, error)

Check password when the user logs in

func GetUser

func GetUser(username string) ([]UserInfo, error)

Get the user information

func InvalidUser

func InvalidUser() UserInfo

Empty session struct for an unauthenticated session

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL