model

package
v0.0.0-...-e0287d8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type User

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

User object that has id, email, password and encrypted password fields

func TestUser

func TestUser(t *testing.T) *User

TestUser object for testing

func (*User) BeforeCreate

func (u *User) BeforeCreate() error

BeforeCreate func. Encrypting password func that encrypts password and writes encrypted version in User's EncryptedPassword field.

func (*User) ComparePassword

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

ComparePassword func. Compares password with its encrypted variant

func (*User) Sanitize

func (u *User) Sanitize()

Sanitize func. Clears users password field

func (*User) Validate

func (u *User) Validate() error

Validate func. Validating user instance for id, email and password

Jump to

Keyboard shortcuts

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