API: Admin EditUser: Make FullName, Email, Website & Location optional (#13562)
* API: Admin EditUser: Make FullName, Email, Website & Location optional * update swagger docs * add Tests Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
24b3b2140a
commit
1bb5c09b5d
4 changed files with 66 additions and 21 deletions
|
@ -155,7 +155,7 @@ func EditUser(ctx *context.APIContext, form api.EditUserOption) {
|
|||
return
|
||||
}
|
||||
|
||||
if len(form.Password) > 0 {
|
||||
if len(form.Password) != 0 {
|
||||
if !password.IsComplexEnough(form.Password) {
|
||||
err := errors.New("PasswordComplexity")
|
||||
ctx.Error(http.StatusBadRequest, "PasswordComplexity", err)
|
||||
|
@ -182,10 +182,23 @@ func EditUser(ctx *context.APIContext, form api.EditUserOption) {
|
|||
}
|
||||
|
||||
u.LoginName = form.LoginName
|
||||
u.FullName = form.FullName
|
||||
u.Email = form.Email
|
||||
u.Website = form.Website
|
||||
u.Location = form.Location
|
||||
|
||||
if form.FullName != nil {
|
||||
u.FullName = *form.FullName
|
||||
}
|
||||
if form.Email != nil {
|
||||
u.Email = *form.Email
|
||||
if len(u.Email) == 0 {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Errorf("email is not allowed to be empty string"))
|
||||
return
|
||||
}
|
||||
}
|
||||
if form.Website != nil {
|
||||
u.Website = *form.Website
|
||||
}
|
||||
if form.Location != nil {
|
||||
u.Location = *form.Location
|
||||
}
|
||||
if form.Active != nil {
|
||||
u.IsActive = *form.Active
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue