user

package
v0.0.0-...-de9ab70 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyExists = errors.New("user already exists")
	ErrNotFound      = errors.New("user not found")
	ErrInternal      = errors.New("internal error")
)

Functions

func CreateUser

func CreateUser(user *UserRegisteration) error

func GetUserDetails

func GetUserDetails(c *fiber.Ctx) error

func UserRouter

func UserRouter(router fiber.Router)

Types

type User

type User struct {
	gorm.Model
	UserDetails
	ID           uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4()" json:"id" validate:"uuid"`
	PasswordHash string    `gorm:"type:varchar(128);not null" json:"password_hash" validate:"required,min=8,max=128"`
	PasswordSalt string    `gorm:"type:varchar(128);not null" json:"password_salt" validate:"required,min=8,max=128"`
}

func FindUser

func FindUser(user *UserCredentials) (User, error)

type UserCredentials

type UserCredentials struct {
	Email    string `gorm:"type:varchar(128);not null;unique" json:"email" validate:"required,email,min=4,max=128"`
	Password string `json:"password" validate:"required,min=8,max=128"`
}

type UserDetails

type UserDetails struct {
	FirstName string `gorm:"type:varchar(128);not null" json:"first_name" validate:"required,min=4,max=128"`
	LastName  string `gorm:"type:varchar(128);not null" json:"last_name" validate:"required,min=4,max=128"`
	Email     string `gorm:"type:varchar(128);not null;unique" json:"email" validate:"required,email,min=4,max=128"`
}

type UserRegisteration

type UserRegisteration struct {
	UserDetails
	Password string `json:"password" validate:"required,min=8,max=128"`
}

Jump to

Keyboard shortcuts

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