improve ldap login
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-05 10:33:09 +11:00
parent 63cfe1fd8d
commit 7f40884115
3 changed files with 43 additions and 44 deletions

View File

@@ -79,6 +79,16 @@ func RegisterUser(c *gin.Context) {
return
}
if len(input.UserName) == 0 {
c.JSON(http.StatusBadRequest, gin.H{"error": "no username specified"})
return
}
if len(input.Password) == 0 {
c.JSON(http.StatusBadRequest, gin.H{"error": "no password specified"})
return
}
u := models.User{}
//u.RoleId = 1
u.UserName = input.UserName
@@ -86,7 +96,7 @@ func RegisterUser(c *gin.Context) {
// Default to regular user role if not specified
if input.RoleId == 0 {
log.Printf("Register no role specified, defaulting to RoleId of 2.\n")
log.Printf("Register no role specified, defaulting to builtin role UserRole with id 2.\n")
u.RoleId = 2
} else {
u.RoleId = input.RoleId