Documentation ¶
Index ¶
- type Models
- type User
- func (u *User) Delete() error
- func (u *User) DeleteByID(id int) error
- func (u *User) GetAll() ([]*User, error)
- func (u *User) GetByEmail(email string) (*User, error)
- func (u *User) GetOne(id int) (*User, error)
- func (u *User) Insert(user User) (int, error)
- func (u *User) PasswordMatches(plainText string) (bool, error)
- func (u *User) ResetPassword(password string) error
- func (u *User) Update() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Models ¶
type Models struct {
User User
}
Models is the type for this package. Note that any model that is included as a member in this type is available to us throughout the application, anywhere that the app variable is used, provided that the model is also added in the New function.
type User ¶
type User struct { ID int `json:"id"` Email string `json:"email"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` Password string `json:"-"` Active int `json:"active"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
User is the structure which holds one user from the database.
func (*User) DeleteByID ¶
DeleteByID deletes one user from the database, by ID
func (*User) GetByEmail ¶
GetByEmail returns one user by email
func (*User) Insert ¶
Insert inserts a new user into the database, and returns the ID of the newly inserted row
func (*User) PasswordMatches ¶
PasswordMatches uses Go's bcrypt package to compare a user supplied password with the hash we have stored for a given user in the database. If the password and hash match, we return true; otherwise, we return false.
func (*User) ResetPassword ¶
ResetPassword is the method we will use to change a user's password.