Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AdminUserMigration = &gormigrate.Migration{ ID: "init_admin", Migrate: func(tx *gorm.DB) error { var err error type adminUser struct { gorm.Model Email string `gorm:"not null;unique"` FirstName string LastName string Password []byte LastLogin *time.Time } if err = tx.CreateTable(&adminUser{}).Error; err != nil { return err } var pwd []byte if pwd, err = bcrypt.GenerateFromPassword([]byte("changeme"), bcrypt.DefaultCost); err != nil { return err } usr := adminUser{ Email: "you@yourcompany.com", Password: pwd, } return tx.Save(&usr).Error }, Rollback: func(tx *gorm.DB) error { return tx.DropTable("admin_users").Error }, }
AdminUserMigration is the migration that creates our user model
Functions ¶
This section is empty.
Types ¶
type Admin ¶
type Admin struct {
// contains filtered or unexported fields
}
Admin abstracts the whole QOR Admin + authentication process
type User ¶
type User struct { gorm.Model Email string `gorm:"not null;unique"` FirstName string LastName string Password []byte LastLogin *time.Time }
User defines how an admin user is represented in database
func (User) CheckPassword ¶
CheckPassword is a simple utility function to check the password given as raw against the user's hashed password
func (User) DisplayName ¶
DisplayName satisfies the interface for Qor Admin
func (*User) HashPassword ¶
HashPassword is a simple utility function to hash the password sent via API before inserting it in database
Click to show internal directories.
Click to hide internal directories.