default to groupid 2 when registering
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -106,7 +106,7 @@ func RegisterUser(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if g == (models.Group{}) {
|
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)
|
log.Println(errString)
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": errString})
|
c.JSON(http.StatusBadRequest, gin.H{"error": errString})
|
||||||
return
|
return
|
||||||
@@ -116,10 +116,10 @@ func RegisterUser(c *gin.Context) {
|
|||||||
} else if input.GroupId > 0 {
|
} else if input.GroupId > 0 {
|
||||||
u.GroupId = input.GroupId
|
u.GroupId = input.GroupId
|
||||||
} else {
|
} else {
|
||||||
errString := fmt.Sprintf("RegisterUser no group specified, must specify either GroupId or GroupName")
|
|
||||||
log.Println(errString)
|
// Default to group Id 2 which is users
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": errString})
|
log.Println("RegisterUser no group id or group name specified, defaulting to built-in group 'Users' ")
|
||||||
return
|
u.GroupId = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -138,15 +138,15 @@ func CreateTables() {
|
|||||||
}
|
}
|
||||||
rowCount, _ = CheckCount("roles")
|
rowCount, _ = CheckCount("roles")
|
||||||
if rowCount == 0 {
|
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)
|
log.Printf("Error adding initial admin role : '%s'", err)
|
||||||
os.Exit(1)
|
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)
|
log.Printf("Error adding initial user role : '%s'", err)
|
||||||
os.Exit(1)
|
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)
|
log.Printf("Error adding initial guest role : '%s'", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user