users

package
v0.0.0-...-242dd47 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestUserLogin

func TestUserLogin(username, password string) (*User, UserState, *time.Time)

TestUserLogin tests the username and password combination entered

func ValidateUser

func ValidateUser(w http.ResponseWriter, r *http.Request, username, password string) (*User, UserState, *time.Time)

ValidateUser returns the user record and response code when a user attempts to sign in

Types

type User

type User struct {
	daggertech.Model
	UserID              string     `daggertech:"size:128,key:true"`
	FirstName           string     `daggertech:"size:128"`
	LastName            string     `daggertech:"size:128"`
	Email               string     `daggertech:"size:128"`
	Password            string     `daggertech:"size:128"`
	LastLogin           *time.Time `daggertech:"type:time"`
	PasswordExpiry      *time.Time `daggertech:"type:time"`
	PasswordForceChange bool       `daggertech:""`
	UnlockTime          *time.Time `daggertech:"type:time"`
}

User is the struct for user details

func CreateUser

func CreateUser(userID, firstname, lastname, email, password string) (*User, bool)

CreateUser creates a new user record

func GetUserByID

func GetUserByID(userID *string) *User

GetUserByID returns the user record for the passed ID

func GetUserByUserID

func GetUserByUserID(userID string) *User

GetUserByUserID returns the user with the specified UserID

func (*User) ForcePasswordExpiry

func (u *User) ForcePasswordExpiry()

ForcePasswordExpiry sets the password forced flag

func (*User) FullName

func (u *User) FullName() string

FullName returns the fullname of the user

func (*User) HashPassword

func (u *User) HashPassword(p string) string

HashPassword creates the password hash

func (*User) Lock

func (u *User) Lock(d time.Duration)

Lock adds a lock to the user record

func (*User) UpdatePassword

func (u *User) UpdatePassword(newPassword, oldPassword string) error

UpdatePassword updates the user password

type UserState

type UserState int

UserState is the result of the user logging in

const (
	// UserOK indicates that the user has successfully logged in
	UserOK UserState = iota
	// UserInvalid indicates that the user has not successfully logged in
	UserInvalid
	// UserPasswordExpired indicates that the user has successfully logged in, but
	// they need to change the password
	UserPasswordExpired
	// UserLocked indicates that the user account has been locked
	UserLocked
)

Jump to

Keyboard shortcuts

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