Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrValidationFailed = errors.New("non valid data")
)
Functions ¶
func GetAllModels ¶
func GetAllModels() []any
GetAllModels returns a list of model instances for gorm migration. Any models added to this package that need to be migrated to the database should be included in this list.
Types ¶
type User ¶
type User struct { gorm.Model Email string `gorm:"UNIQUE;NOT NULL" json:"email"` Username string `json:"username"` Password string `json:"password"` }
func (*User) ComparePassword ¶
ComparePassword will evaluate the provided password witht the one stored against the user by hashing it first. If the passwords match, true will be returned (with a nil, error) otherswise, false will be returned.
If an error is returned, it means that the passwords weren't able to be compared, and so the result cannot be trusted.
func (*User) SetPassword ¶
SetPassword will accept a string password and attempt to hash and salt it. Providing the hash is successful, the Password field of the User will be updated.
Click to show internal directories.
Click to hide internal directories.