user

package
v0.0.0-...-17c7b16 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2021 License: GPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

Config - used for access to config properties

Functions

func ComparePassword

func ComparePassword(hashedPass string, unhashedPass string) bool

ComparePassword encrypts and compares an existing password with a given one

func CurrentUserID

func CurrentUserID(r *http.Request, signingKey string) int

CurrentUserID uses the auth token to return the current user's id

func Delete

func Delete(userID int) error

Delete deletes the user record identified by the given userID

func GenerateAdminUser

func GenerateAdminUser(userName string, pass string) error

GenerateAdminUser creates an admin user record

func RegisterHandlers

func RegisterHandlers(mainConfig config.Configuration)

RegisterHandlers - registers all user endpoints for the application

func ValidateAdmin

func ValidateAdmin(next http.HandlerFunc) http.HandlerFunc

ValidateAdmin is middleware for validating whether or not the user is an admin user

Types

type User

type User struct {
	UserID            int       `json:"userID"`
	Login             string    `json:"login"`
	Password          string    `json:"password"`
	FirstName         string    `json:"firstName"`
	LastName          string    `json:"lastName"`
	IsAdmin           bool      `json:"isAdmin"`
	PasswordCanExpire bool      `json:"passwordCanExpire"`
	IsDeleted         bool      `json:"isDeleted"`
	ExpireDate        time.Time `json:"expireDate"`
	LastLogin         time.Time `json:"lastLogin"`
	DateCreated       time.Time `json:"dateCreated"`
	DateUpdated       time.Time `json:"dateUpdated"`
	DateDeleted       time.Time `json:"dateDeleted"`
}

User - site user

func Create

func Create(user User) (User, error)

Create adds a user record to the database

func FetchUserByID

func FetchUserByID(userID int) User

FetchUserByID - looks for a record with a userID value that matches the one give. Returns an empty user if one is not found.

func FindExistingUser

func FindExistingUser(userName string) User

FindExistingUser finds a user record by their user propery

func Update

func Update(updatedUser User) (User, error)

Update updates a user record in the database

Jump to

Keyboard shortcuts

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