user

package
v0.0.0-...-7c1bd43 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IDToString

func IDToString(uid ID) string

IDToString converts user.ID to string

Types

type ID

type ID = pgtype.UUID

type Props

type Props struct {
	Email string `json:"email" db:"email" validate:"required,email,max=254"`
	Name  string `json:"name" db:"name" validate:"required,min=3,max=64,name"`
}

type Registration

type Registration struct {
	Props
	Password string `json:"password" validate:"required,min=6"`
}

type User

type User struct {
	Props

	// ID is unique user ID
	ID pgtype.UUID `json:"id" db:"id"`

	// PasswordHash contains encrypted password and salt in bcrypt format
	PasswordHash string `json:"-" db:"password"`
}

func (User) ComparePassword

func (u User) ComparePassword(pwd string) (bool, error)

ComparePassword compares password with hashed in user

func (*User) SetPassword

func (u *User) SetPassword(newPassword string) error

SetPassword encrypts and updates user password

type Users

type Users = []User

Jump to

Keyboard shortcuts

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