mirror of
https://github.com/go-gitea/gitea
synced 2024-08-23 02:34:55 +02:00
Fix incorrect/Improve error handle in edit user page (#23805)
Changes: - `RenderWithErr` should render `tplUserEdit` not `tplUserNew` in edit page - If error occurred in `HandleUsernameChange` redirect to original edit page instead of user list page
This commit is contained in:
parent
ffd22697ba
commit
06d9d9e407
|
@ -316,13 +316,13 @@ func EditUserPost(ctx *context.Context) {
|
||||||
log.Error(err.Error())
|
log.Error(err.Error())
|
||||||
errMsg = ctx.Tr("auth.password_pwned_err")
|
errMsg = ctx.Tr("auth.password_pwned_err")
|
||||||
}
|
}
|
||||||
ctx.RenderWithErr(errMsg, tplUserNew, &form)
|
ctx.RenderWithErr(errMsg, tplUserEdit, &form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := user_model.ValidateEmail(form.Email); err != nil {
|
if err := user_model.ValidateEmail(form.Email); err != nil {
|
||||||
ctx.Data["Err_Email"] = true
|
ctx.Data["Err_Email"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("form.email_error"), tplUserNew, &form)
|
ctx.RenderWithErr(ctx.Tr("form.email_error"), tplUserEdit, &form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +338,10 @@ func EditUserPost(ctx *context.Context) {
|
||||||
|
|
||||||
if len(form.UserName) != 0 && u.Name != form.UserName {
|
if len(form.UserName) != 0 && u.Name != form.UserName {
|
||||||
if err := user_setting.HandleUsernameChange(ctx, u, form.UserName); err != nil {
|
if err := user_setting.HandleUsernameChange(ctx, u, form.UserName); err != nil {
|
||||||
ctx.Redirect(setting.AppSubURL + "/admin/users")
|
if ctx.Written() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.RenderWithErr(ctx.Flash.ErrorMsg, tplUserEdit, &form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
u.Name = form.UserName
|
u.Name = form.UserName
|
||||||
|
|
Loading…
Reference in a new issue