Admin: Add user page

This commit is contained in:
Tom Wiesing 2023-01-04 16:10:55 +01:00
parent bc0e92bdac
commit d34e85a18f
No known key found for this signature in database
24 changed files with 456 additions and 77 deletions

View file

@ -0,0 +1,2 @@
// Package contains all database models
package models

View file

@ -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
}