models

package
v0.0.0-...-aff41f5 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Password

type Password string

Password represents a password

func (Password) Compare

func (p Password) Compare(hash string) (bool, error)

Compare compares the password with the hash

func (Password) GenerateHash

func (p Password) GenerateHash() (string, error)

GenerateHash generates a hash for the password

func (Password) Validate

func (p Password) Validate() error

Validate validates the password

type User

type User struct {
	ID               string    `json:"id"`
	Name             string    `json:"name"`
	ScreenName       string    `json:"screen_name"`
	PasswordHash     string    `json:"password_hash"`
	Email            string    `json:"email"`
	Bio              string    `json:"bio"`
	Location         string    `json:"location"`
	Website          string    `json:"website"`
	ProfileImageURL  string    `json:"profile_image_url"`
	ProfileBannerURL string    `json:"profile_banner_url"`
	BirthDate        time.Time `json:"birth_date"`
	FollowersCount   int       `json:"followers_count"`
	FollowingsCount  int       `json:"followings_count"`
	CreatedAt        time.Time `json:"created_at"`
	UpdatedAt        time.Time `json:"updated_at"`
}

User represents a generic user

func (User) PB

func (u User) PB() *userpb.User

func (User) PasswordIsValid

func (u User) PasswordIsValid(password Password) (bool, error)

PasswordIsValid determines wether the given password matches with the user's password hash

func (User) Validate

func (u User) Validate() error

Validate validates the user fields

Jump to

Keyboard shortcuts

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