user

package
v0.0.0-...-50e7ee4 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 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 Group

type Group struct {
	ID      pgtype.UUID `json:"id" db:"id"`
	Name    string      `json:"name" db:"name"`
	OwnerID ID          `json:"owner_id" db:"owner_id"`
}

type GroupID

type GroupID = pgtype.UUID

type GroupInfo

type GroupInfo struct {
	Group
	Members Users `json:"members"`
}

type Groups

type Groups = []Group

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