Documentation ¶
Index ¶
- func Hash(password string) ([]byte, error)
- func VerifyPassword(hashedPassword, password string) error
- type Config
- type Database
- type Service
- type User
- func (u *User) Create(db *gorm.DB) (*User, error)
- func (u *User) Delete(db *gorm.DB, uid uint32) (int64, error)
- func (u *User) FindByEmail(db *gorm.DB, email string) (*User, error)
- func (u *User) FindByID(db *gorm.DB, uid uint32) (*User, error)
- func (u *User) HashPassword() error
- func (u *User) Update(db *gorm.DB, uid uint32) (*User, error)
- func (u *User) Validate() error
- func (u *User) ValidateLogin() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VerifyPassword ¶
VerifyPassword password and the hashed password is the same
Types ¶
type Database ¶
type Database struct { Type string `json:"type"` Host string `json:"host"` Port int `json:"port"` User string `json:"user"` DatabaseName string `json:"database"` Password string `json:"password"` }
Database structure configuration file format
type Service ¶
type Service struct { Port int `json:"port"` APISecret string `json:"secret"` LogLevel string `json:"loglevel"` }
Service structure configuration file format
type User ¶
type User struct { ID uint32 `gorm:"primary_key;auto_increment" json:"id"` FirstName string `gorm:"size:255;not null;" json:"firstname"` LastName string `gorm:"size:255;not null;" json:"lastname"` Email string `gorm:"size:255;not null;unique" json:"email"` Password string `gorm:"size:100;not null;" json:"password"` PhoneNumber int `gorm:"size:15;" json:"phone_number"` Country string `gorm:"size:100;" json:"country"` PostalCode int `gorm:"size:5;" json:"postal_code"` CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"` UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"` }
User structure for a user
func (*User) FindByEmail ¶
FindByEmail user by using email in database
func (*User) ValidateLogin ¶
ValidateLogin basic authentication provided
Click to show internal directories.
Click to hide internal directories.