Admin: Add user page
This commit is contained in:
parent
bc0e92bdac
commit
d34e85a18f
24 changed files with 456 additions and 77 deletions
2
internal/models/models.go
Normal file
2
internal/models/models.go
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
// Package contains all database models
|
||||
package models
|
||||
|
|
@ -10,9 +10,33 @@ type User struct {
|
|||
User string `gorm:"column:user;not null;unique"` // name of the user
|
||||
PasswordHash []byte `gorm:"column:password"` // password of the user, hashed
|
||||
|
||||
TOTPEnabled bool `gorm:"column:totpenabled"` // is totp enabled for the user
|
||||
TOTPEnabled *bool `gorm:"column:totpenabled"` // is totp enabled for the user
|
||||
TOTPURL string `gorm:"column:totp"` // the totp of the user
|
||||
|
||||
Enabled bool `gorm:"enabled;not null"`
|
||||
Admin bool `gorm:"column:admin;not null"`
|
||||
Enabled *bool `gorm:"enabled;not null"`
|
||||
Admin *bool `gorm:"column:admin;not null"`
|
||||
}
|
||||
|
||||
func (user *User) IsAdmin() bool {
|
||||
return user.Admin != nil && *user.Admin
|
||||
}
|
||||
|
||||
func (user *User) SetAdmin(v bool) {
|
||||
user.Admin = &v
|
||||
}
|
||||
|
||||
func (user *User) IsEnabled() bool {
|
||||
return user.Enabled != nil && *user.Enabled
|
||||
}
|
||||
|
||||
func (user *User) SetEnabled(v bool) {
|
||||
user.Enabled = &v
|
||||
}
|
||||
|
||||
func (user *User) IsTOTPEnabled() bool {
|
||||
return user.TOTPEnabled != nil && *user.TOTPEnabled
|
||||
}
|
||||
|
||||
func (user *User) SetTOTPEnabled(v bool) {
|
||||
user.TOTPEnabled = &v
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue