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 /models/user.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 'models/user.go')
-rw-r--r-- | models/user.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/models/user.go b/models/user.go index 73178f256c..d3f1b16c2e 100644 --- a/models/user.go +++ b/models/user.go @@ -913,19 +913,19 @@ func ChangeUserName(u *User, newUserName string) (err error) { return err } - isExist, err := IsUserExist(0, newUserName) - if err != nil { - return err - } else if isExist { - return ErrUserAlreadyExist{newUserName} - } - sess := x.NewSession() defer sess.Close() if err = sess.Begin(); err != nil { return err } + isExist, err := isUserExist(sess, 0, newUserName) + if err != nil { + return err + } else if isExist { + return ErrUserAlreadyExist{newUserName} + } + if _, err = sess.Exec("UPDATE `repository` SET owner_name=? WHERE owner_name=?", newUserName, u.Name); err != nil { return fmt.Errorf("Change repo owner name: %v", err) } |