Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPasswordHash ¶
func CleanUpSessions ¶
func CleanUpSessions() (err error)
func HashPassword ¶
Types ¶
type Session ¶
type Session struct {
ID uint `gorm:"primary_key" json:"id"`
Uuid string `gorm:"not null;unique" json:"uuid"` // Set field as not nullable and unique
UserID uint `gorm:"index" valid:"required"`
ExpiresAt time.Time `json:"expiresAt" valid:"required"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (*Session) BeforeCreate ¶
type User ¶
type User struct {
ID uint `gorm:"primary_key" json:"id"`
Uuid string `gorm:"not null;unique" json:"uuid"` // Set field as not nullable and unique
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
FirstName string `gorm:"size:255" valid:"optional" json:"firstName"` // Default size for string is 255, reset it with this tag
LastName string `gorm:"size:255" valid:"optional" json:"lastName"` // Default size for string is 255, reset it with this tag
Email string `gorm:"not null;unique" valid:"required,email" json:"email"` // Set field as not nullable and unique
Password string `gorm:"size:255" json:"password"`
Sessions []Session `json:"sessions"`
}
func (*User) BeforeCreate ¶
GORM callback: Encode password before create
func (*User) BeforeUpdate ¶
Detect if password was set, encode it if needed
Click to show internal directories.
Click to hide internal directories.