diff --git a/controllers/auth.go b/controllers/auth.go index 3cf6393..3e4ed15 100644 --- a/controllers/auth.go +++ b/controllers/auth.go @@ -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 } /* diff --git a/models/setup.go b/models/setup.go index 23c3204..b4acdf9 100644 --- a/models/setup.go +++ b/models/setup.go @@ -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) }