mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-27 04:07:08 +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:
parent
d989247bb0
commit
6b3b6f1833
9 changed files with 122 additions and 43 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue