mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
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>
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user