diff options
author | 6543 <6543@obermui.de> | 2021-01-10 13:14:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-10 14:14:02 +0200 |
commit | 6b3b6f1833d07383d24d68ec220a18315ac36809 (patch) | |
tree | aeceb687845f71a493b64c223297c0567d7f6bf5 /routers/admin/users.go | |
parent | d989247bb08d2b8eb144e7a0edeaedfc26d08175 (diff) | |
download | gitea-6b3b6f1833d07383d24d68ec220a18315ac36809.tar.gz gitea-6b3b6f1833d07383d24d68ec220a18315ac36809.zip |
Add option to change username to the admin panel (#14229)
Co-authored-by: Bwko <bouwko@gmail.com>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'routers/admin/users.go')
-rw-r--r-- | routers/admin/users.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/routers/admin/users.go b/routers/admin/users.go index 1dc6d5bbe2..8a848b1f9d 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -18,6 +18,7 @@ import ( "code.gitea.io/gitea/modules/password" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/routers" + router_user_setting "code.gitea.io/gitea/routers/user/setting" "code.gitea.io/gitea/services/mailer" ) @@ -269,6 +270,15 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) { u.HashPassword(form.Password) } + if len(form.UserName) != 0 && u.Name != form.UserName { + if err := router_user_setting.HandleUsernameChange(ctx, u, form.UserName); err != nil { + ctx.Redirect(setting.AppSubURL + "/admin/users") + return + } + u.Name = form.UserName + u.LowerName = strings.ToLower(form.UserName) + } + if form.Reset2FA { tf, err := models.GetTwoFactorByUID(u.ID) if err != nil && !models.IsErrTwoFactorNotEnrolled(err) { |