model

package
v0.0.0-...-b856a18 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncryptMessage

func EncryptMessage(password string) (string, error)

encrypt string using bcrypt

func RequiredIf

func RequiredIf(cond bool) validation.RuleFunc

helper func: if cond, validate that value cannot be blank

Types

type User

type User struct {
	Id                int    `json:"id"`
	Email             string `json:"email"`
	Password          string `json:"password,omitempty"`
	EncryptedPassword string `json:"-"`
}

this struct corresponds with "users" table from db

func TestUser

func TestUser(t *testing.T) *User

example user for tests

func (*User) BeforeCreate

func (u *User) BeforeCreate() error

encrypt password defore passing to db

func (*User) ComparePassword

func (u *User) ComparePassword(password string) bool

compare stored encrypted password with inputted one

func (*User) Sanitize

func (u *User) Sanitize()

hide password for safe responding

func (*User) Validate

func (u *User) Validate() error

validate information before passing it to db(using ozzo-validation)

Jump to

Keyboard shortcuts

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