Add admin-route & dropdown-menu. Add clear-cache & create-code. Adjustments for activation-code and user models. Add sweet-alert for admin-tools.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package models
|
||||
|
||||
type ActivationCode struct {
|
||||
Code string
|
||||
Used bool
|
||||
Code string `gorm:"primary_key"`
|
||||
UserRole Role
|
||||
UsedForUsername string
|
||||
UsedFor User `gorm:"foreignKey:UsedForUsername"`
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ func ConnectDatabase() {
|
||||
var code ActivationCode
|
||||
if err := database.First(&code).Error; err != nil {
|
||||
firstCode := utils.GenerateActivationCode()
|
||||
database.Create(&ActivationCode{Code: firstCode, Used: false})
|
||||
log.Println("Created first activation code: " + firstCode)
|
||||
database.Create(&ActivationCode{Code: firstCode, UserRole: AdminRole})
|
||||
log.Println("Created first activation code with ADMIN role:\n" + firstCode)
|
||||
}
|
||||
}
|
||||
err = database.AutoMigrate(&Game{})
|
||||
|
||||
@@ -4,4 +4,13 @@ type User struct {
|
||||
Username string `json:"username" gorm:"primary_key"`
|
||||
Password string `json:"password"`
|
||||
Enabled bool `json:"enabled" default:"1"`
|
||||
UserRole Role `json:"user_role" default:"READER"`
|
||||
}
|
||||
|
||||
type Role string
|
||||
|
||||
const (
|
||||
AdminRole Role = "ADMIN"
|
||||
AuthorRole Role = "AUTHOR"
|
||||
ReaderRole Role = "READER"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user