user

package
v0.0.0-...-84f9aa2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUser

func AddUser(clients *conn.Clients, ur *Registration, rr *RecaptchaResponse) (int64, error)

AddUser inserts user into user table

func ChangePassword

func ChangePassword(clients *conn.Clients, idUser int64, newPassword string) error

ChangePassword changes a user's password

func DeleteAbout

func DeleteAbout(clients *conn.Clients, idUser int64) error

DeleteAbout deletes user_profile details of a user

func GetUsername

func GetUsername(clients *conn.Clients, idUser int64) (string, error)

GetUsername gets username by id

func RouteAuth

func RouteAuth(clients *conn.Clients) chi.Router

RouteAuth handles signups

func RouteUser

func RouteUser(clients *conn.Clients) chi.Router

RouteUser handles user requests

func UpdateAbout

func UpdateAbout(clients *conn.Clients, idUser int64, a *About) error

UpdateAbout updates user_profile details of a user

Types

type About

type About struct {
	Title string `db:"title,omitempty" json:"title,omitempty"`
	About string `db:"about,omitempty" json:"about,omitempty"`
}

About contains user_profile details

func GetAbout

func GetAbout(clients *conn.Clients, idUser int64) (*About, error)

GetAbout gets user_profile details of a user

type IDs

type IDs struct {
	IDs []int64 `json:"ids" validate:"required"`
}

IDs contains a list of user IDs

type Login

type Login struct {
	Username string `json:"username" validate:"required,min=3,max=20,alphanum"`
	Password string `json:"password" validate:"required,min=6,max=255"`
}

Login contains user login details

type PasswordChange

type PasswordChange struct {
	OldPassword string `json:"oldPassword" validate:"required,min=6,max=255"`
	NewPassword string `json:"newPassword" validate:"required,min=6,max=255"`
}

PasswordChange for a user changing passwords

type RecaptchaResponse

type RecaptchaResponse struct {
	Success     bool     `json:"success"`
	ChallengeTS string   `json:"challenge_ts"`
	Hostname    string   `json:"hostname"`
	Score       float64  `json:"score"`
	Action      string   `json:"action"`
	ErrorCodes  []string `json:"error-codes"`
}

RecaptchaResponse recaptcha response from verification step See: https://developers.google.com/recaptcha/docs/v3

type Registration

type Registration struct {
	Username       string `json:"username" validate:"required,min=3,max=20,alphanum"`
	Password       string `json:"password" validate:"required,min=6,max=255"`
	Email          string `json:"email" validate:"required,email"`
	RecaptchaToken string `json:"recaptchaToken" validate:"required"`
}

Registration contains user registration details

type User

type User struct {
	ID       int64  `db:"id_user,omitempty" json:"id,omitempty"`
	Username string `db:"username,omitempty" json:"username,omitempty"`
	Password string `db:"password,omitempty" json:"-"`
	Email    string `db:"email,omitempty" json:"email,omitempty"`
	Created  string `db:"created,omitempty" json:"created,omitempty"`
	Modified string `db:"modified,omitempty" json:"modified,omitempty"`
}

User contains contains data from user tables

func GetUser

func GetUser(clients *conn.Clients, idUser int64) (*User, error)

GetUser gets single user including password

func GetUserByUsername

func GetUserByUsername(clients *conn.Clients, username string) (*User, error)

GetUserByUsername gets single user including password

type Username

type Username struct {
	ID       int64  `json:"id" validate:"required"`
	Username string `json:"username" validate:"required,min=3,max=20,alphanum"`
}

Username contains username and ID pair

func GetUsernames

func GetUsernames(clients *conn.Clients, uids *IDs) ([]*Username, error)

GetUsernames creates a slice of username and ID pairs

Jump to

Keyboard shortcuts

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