updates
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
type RegisterInput struct {
|
||||
Username string `json:"username" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
RoleId int `json:"roleid"`
|
||||
}
|
||||
|
||||
type LoginInput struct {
|
||||
@@ -32,10 +33,18 @@ func Register(c *gin.Context) {
|
||||
}
|
||||
|
||||
u := models.User{}
|
||||
u.RoleId = 1
|
||||
//u.RoleId = 1
|
||||
u.UserName = input.Username
|
||||
u.Password = input.Password
|
||||
|
||||
// Default to regular user role if not specified
|
||||
if input.RoleId == 0 {
|
||||
fmt.Printf("Register no role specified, defaulting to RoleId of 2.\n")
|
||||
u.RoleId = 2
|
||||
} else {
|
||||
u.RoleId = input.RoleId
|
||||
}
|
||||
|
||||
//remove spaces in username
|
||||
u.UserName = html.EscapeString(strings.TrimSpace(u.UserName))
|
||||
|
||||
|
Reference in New Issue
Block a user