users

package
v0.0.0-...-c190d2f Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var COLUMNS = map[string]string{
	"id":            "ID",
	"applicationid": "ApplicationID",
	"username":      "Username",
	"first":         "First",
	"last":          "Last",
	"full":          "Full",
	"email":         "Email",
	"password":      "Password",
	"data":          "Data",
	"createdat":     "CreatedAt",
	"lastupdatedat": "LastUpdatedAt",
}

Define a map to store column names

Functions

func CompareHash

func CompareHash(str, hash string) bool

Compares the provided hash with the given string

func Delete

func Delete(db *model.Database, id uuid.UUID, uid uuid.UUID) (int, error)

Deletes a user from the database, ID should be parsed to a UUID to ensure its validity. The 'int' return on this function is the HTTP status code which should be sent back to the user upon calling this function.

func GetApplicationColumns

func GetApplicationColumns(db *model.Database, appId uuid.UUID) ([]string, error)

Retrieves a list of the valid columns for an application based on the given ID.

func HashString

func HashString(str string) string

Hashes the provided string

func Insert

func Insert(db *model.Database, user *model.User) (int, error)

Inserts a new user into the database. The 'int' return of this function is the HTTP status code that should be sent back to the user upon calling this function.

func New

func New(appId uuid.UUID, data *model.UserData) *model.User

Creates a new user with the given data and application ID.

func Retrieve

func Retrieve(db *model.Database, id uuid.UUID, uid uuid.UUID) (*map[string]string, int, error)

Retrieves a user from the database based on the given ID.

func RetrieveAll

func RetrieveAll(db *model.Database, id uuid.UUID) ([]map[string]string, int, error)

Retrieves all users from the database based on the given application ID.

func Update

func Update(db *model.Database, id uuid.UUID, uid uuid.UUID, data *model.UserData) (*model.User, int, error)

Updates a user in the database. The 'id' parameter should be parsed into a UUID to ensure validity. Only provided parameters will be updated. The 'int' return of this function is the HTTP status code that should be sent back to the user upon calling this function.

func Validate

func Validate(db *model.Database, appId uuid.UUID, user *model.User) (string, int, error)

Validates the user objects column inputs based on the application's columns. Returns a message and status code for use in the response.

func ValidateLogin

func ValidateLogin(db *model.Database, id uuid.UUID, columns []string, user *model.UserData) (*model.User, string, int, error)

Validates a user's login credentials. The id parameter should be parsed to a UUID to ensure its validity. The columns parameter is a list of columns to be checked against the user's data. The user parameter is a pointer to a user model which contains the user's inputted data.

Types

This section is empty.

Jump to

Keyboard shortcuts

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