accts

package
v0.0.0-...-36033d1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const BadRequest = 400

Variables

View Source
var ErrorCode int // http-status code for errors

Functions

func ReadUserIDByToken

func ReadUserIDByToken(tgtToken string, fieldErr *fields.GrammarError) int

returns the user id asscoiated by the auth-token

Types

type Account

type Account struct {
	ID       int    `json:"id" form:"id"`
	Fname    string `json:"fname" form:"fname"`
	Lname    string `json:"lname" form:"lname"`
	Address  string `json:"address" form:"address"`
	Username string `json:"username" form:"username"`
	Password string `json:"password" form:"password"`
}

meant to be binded to new acct info

type AuthError

type AuthError struct {
	ErrMsgs []string
}

meant to hold err strings related to authentication and account creation

func (*AuthError) AddMsg

func (credErr *AuthError) AddMsg(statusCode int, str string)

helper funct: takes a pointer to an Authentication Error, HttpStatusCode and a string msg as parameters and sets the values for the AuthError struct. By default content-type is of type 'application/json'

type LoginStatus

type LoginStatus struct {
	UserID int
	Status string
}

type Passwords

type Passwords struct {
	ID       int    `db:"id" json:"id" form:"id"`
	UserID   int    `db:"user_id" json:"user_id" form:"user_id"`
	Password []byte `db:"password" json:"password" form:"password"`
}

func ReadHashByID

func ReadHashByID(userID int) ([]*Passwords, fields.GrammarError)

returns a pswd hash given userid if the id doesn't exist it error

type Registered

type Registered struct {
	UserID int
	Msg    string
}

func AddAccount

func AddAccount(acct *Account) (*Registered, fields.GrammarError)

adds the account info to the appropiate tables w/ the database

type Tokens

type Tokens struct {
	ID     int    `db:"id" json:"id" form:"id"`
	UserID int    `db:"user_id" json:"user_id"`
	Token  []byte `db:"token" json:"token"`
}

func GenerateToken

func GenerateToken(username string, acctErr *fields.GrammarError) Tokens

creates an auth-token for a user and stores it in the database

func LogOut

func LogOut(userID int, fieldErr *fields.GrammarError) Tokens

When users logout they delete their session token

type UserContacts

type UserContacts struct {
	ID      int    `db:"id" json:"id"`
	UserID  int    `db:"user_id" json:"user_id"`
	Fname   string `db:"fname" json:"fname" form:"fname"`
	Lname   string `db:"lname" json:"lname" form:"lname"`
	Address string `db:"address" json:"address"`
}

func ReadUserContact

func ReadUserContact() ([]*UserContacts, fields.GrammarError)

returns the list of all existing users

func ReadUserContactByID

func ReadUserContactByID(id int) ([]*UserContacts, fields.GrammarError)

returns a user given the id if the id doesn't exist it error

type Usernames

type Usernames struct {
	ID       int    `db:"id" json:"id"`
	Username string `db:"username" json:"username"`
}

func DeleteAcct

func DeleteAcct(user Usernames) ([]*Usernames, fields.GrammarError)

Deletes the User account which cascades to delete their invoices too

func ReadUsernameByID

func ReadUsernameByID(userID int, fieldErr *fields.GrammarError) []*Usernames

Jump to

Keyboard shortcuts

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