aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2023-03-31 02:27:00 +0900
committerGitHub <noreply@github.com>2023-03-30 13:27:00 -0400
commit06d9d9e40794db9cbb00cdc893dea86d694389ad (patch)
treef9e616781e1142dd0c3250554d9088bfed8112ea /routers
parentffd22697baa8c1e28c6acb8a424359b9c5c5a58e (diff)
downloadgitea-06d9d9e40794db9cbb00cdc893dea86d694389ad.tar.gz
gitea-06d9d9e40794db9cbb00cdc893dea86d694389ad.zip
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
Diffstat (limited to 'routers')
-rw-r--r--routers/web/admin/users.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go
index 5fb2a3e5d6..531f14d086 100644
--- a/routers/web/admin/users.go
+++ b/routers/web/admin/users.go
@@ -316,13 +316,13 @@ func EditUserPost(ctx *context.Context) {
log.Error(err.Error())
errMsg = ctx.Tr("auth.password_pwned_err")
}
- ctx.RenderWithErr(errMsg, tplUserNew, &form)
+ ctx.RenderWithErr(errMsg, tplUserEdit, &form)
return
}
if err := user_model.ValidateEmail(form.Email); err != nil {
ctx.Data["Err_Email"] = true
- ctx.RenderWithErr(ctx.Tr("form.email_error"), tplUserNew, &form)
+ ctx.RenderWithErr(ctx.Tr("form.email_error"), tplUserEdit, &form)
return
}
@@ -338,7 +338,10 @@ func EditUserPost(ctx *context.Context) {
if len(form.UserName) != 0 && u.Name != form.UserName {
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
}
u.Name = form.UserName