Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct { ID uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"` CreatedAt time.Time `gorm:"default:now();not null"` UpdatedAt time.Time `gorm:"default:now();not null"` }
Base contains common columns for all tables.
type User ¶
type User struct { Base Username string `gorm:"not null;unique_index"` Password string `gorm:"not null"` }
User resolves the user type.
func (*User) BeforeSave ¶
func (*User) CheckPassword ¶
Database will only save the hashed string, you should check it by util function.
if err := userModel.CheckPassword("password0"); err != nil { password error }
func (*User) SetPassword ¶
What's bcrypt? https://en.wikipedia.org/wiki/Bcrypt Golang bcrypt doc: https://godoc.org/golang.org/x/crypto/bcrypt You can change the value in bcrypt.DefaultCost to adjust the security index.
err := userModel.SetPassword("password0")
Click to show internal directories.
Click to hide internal directories.