Documentation
¶
Index ¶
- func EnsureDBElementsExists(db *sql.DB, config *config.DB, logger *log.Logger) error
- type User
- func (u *User) CheckEmailDomain(domains []string) bool
- func (u *User) CheckPassword(password string) bool
- func (u *User) Create(db *sql.DB) error
- func (u *User) CreateJWTToken(role, secret string, exp int) (string, error)
- func (u *User) CreateRandomPassword(length int) error
- func (u *User) CreateResetToken(db *sql.DB, secret string) error
- func (u *User) FindByEmail(db *sql.DB) error
- func (u *User) FindByID(db *sql.DB) error
- func (u *User) GetMapRepresentation() map[string]interface{}
- func (u *User) HashPassword() error
- func (u *User) UpdatePassword(db *sql.DB, password string) error
- func (u *User) UpdateStatus(db *sql.DB, confirm bool) error
- func (u *User) ValidateResetToken(db *sql.DB, secret, token string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type User ¶
type User struct { ID string `json:"id"` Email string `json:"email"` Password string `json:"password"` Confirmed bool ConfirmToken sql.NullString ResetPasswordToken sql.NullString }
User represents a user of our auth system
func (*User) CheckEmailDomain ¶
CheckEmailDomain checks if the user's email address matches the provied domains list
func (*User) CheckPassword ¶
CheckPassword checks if the provided password matches the actual user's password hash
func (*User) CreateJWTToken ¶
CreateJWTToken creates a new JWT token for the user
func (*User) CreateRandomPassword ¶
GeneratePassword generate random password
func (*User) CreateResetToken ¶
CreateResetToken create a random reset token
func (*User) FindByEmail ¶
FindByEmail allows us to find a user by its email (used for authentication)
func (*User) GetMapRepresentation ¶
GetMapRepresentation return the json representation of the user without secret informations
func (*User) HashPassword ¶
HashPassword hashes the user's password using bcrypt
func (*User) UpdatePassword ¶
UpdatePassword edits the user's password in memory and in db
func (*User) UpdateStatus ¶
UpdateStatus edits the user's confirmation status