Documentation
¶
Index ¶
- type Models
- type Plan
- 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 ¶
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 Plan ¶
type Plan struct { ID int PlanName string PlanAmount int PlanAmountFormatted string CreatedAt time.Time UpdatedAt time.Time }
Plan is the type for subscription plans
func (*Plan) AmountForDisplay ¶
AmountForDisplay formats the price we have in the DB as a currency string
type User ¶
type User struct { ID int Email string FirstName string LastName string Password string Active int IsAdmin int CreatedAt time.Time UpdatedAt time.Time Plan *Plan }
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.