default to groupid 2 when registering
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-08 14:47:52 +11:00
parent d1eecc5c4f
commit fd626a9cbe
2 changed files with 8 additions and 8 deletions

View File

@@ -106,7 +106,7 @@ func RegisterUser(c *gin.Context) {
return
}
if g == (models.Group{}) {
errString := fmt.Sprintf("RegisterUser specified group not found")
errString := fmt.Sprintf("RegisterUser specified group '%s' not found\n", input.GroupName)
log.Println(errString)
c.JSON(http.StatusBadRequest, gin.H{"error": errString})
return
@@ -116,10 +116,10 @@ func RegisterUser(c *gin.Context) {
} else if input.GroupId > 0 {
u.GroupId = input.GroupId
} else {
errString := fmt.Sprintf("RegisterUser no group specified, must specify either GroupId or GroupName")
log.Println(errString)
c.JSON(http.StatusBadRequest, gin.H{"error": errString})
return
// Default to group Id 2 which is users
log.Println("RegisterUser no group id or group name specified, defaulting to built-in group 'Users' ")
u.GroupId = 2
}
/*

View File

@@ -138,15 +138,15 @@ func CreateTables() {
}
rowCount, _ = CheckCount("roles")
if rowCount == 0 {
if _, err = db.Exec("INSERT INTO roles VALUES(1, 'Admin', false, true, '');"); err != nil {
if _, err = db.Exec("INSERT INTO roles VALUES(1, 'Admin', false);"); err != nil {
log.Printf("Error adding initial admin role : '%s'", err)
os.Exit(1)
}
if _, err = db.Exec("INSERT INTO roles VALUES(2, 'UserRole', false, false, '');"); err != nil {
if _, err = db.Exec("INSERT INTO roles VALUES(2, 'UserRole', false);"); err != nil {
log.Printf("Error adding initial user role : '%s'", err)
os.Exit(1)
}
if _, err = db.Exec("INSERT INTO roles VALUES(3, 'GuestRole', true, false, '');"); err != nil {
if _, err = db.Exec("INSERT INTO roles VALUES(3, 'GuestRole', true);"); err != nil {
log.Printf("Error adding initial guest role : '%s'", err)
os.Exit(1)
}