diff options
author | a1012112796 <1012112796@qq.com> | 2021-12-02 19:52:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-02 19:52:08 +0800 |
commit | 9a8532d928ef0ef5606227d1774ca7387a3a83d5 (patch) | |
tree | 5148deb86fb70bd9b5f9960f2b30d8a2dea9800f | |
parent | d29a0fc3beeef61bb30a11c70d2aecb2e28310f1 (diff) | |
download | gitea-9a8532d928ef0ef5606227d1774ca7387a3a83d5.tar.gz gitea-9a8532d928ef0ef5606227d1774ca7387a3a83d5.zip |
fix 500 error while use a reserved name in org rename (#17878) (#17881)
fix #17876
Signed-off-by: a1012112796 <1012112796@qq.com>
-rw-r--r-- | models/user.go | 3 | ||||
-rw-r--r-- | routers/web/org/setting.go | 2 |
2 files changed, 1 insertions, 4 deletions
diff --git a/models/user.go b/models/user.go index 9a15de0822..37876063e3 100644 --- a/models/user.go +++ b/models/user.go @@ -77,9 +77,6 @@ var ( // ErrEmailNotActivated e-mail address has not been activated error ErrEmailNotActivated = errors.New("E-mail address has not been activated") - // ErrUserNameIllegal user name contains illegal characters error - ErrUserNameIllegal = errors.New("User name contains illegal characters") - // ErrLoginSourceNotActived login source is not actived error ErrLoginSourceNotActived = errors.New("Login source is not actived") diff --git a/routers/web/org/setting.go b/routers/web/org/setting.go index 3414bb8dda..999a9b3566 100644 --- a/routers/web/org/setting.go +++ b/routers/web/org/setting.go @@ -65,7 +65,7 @@ func SettingsPost(ctx *context.Context) { ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), tplSettingsOptions, &form) return } else if err = models.ChangeUserName(org, form.Name); err != nil { - if err == models.ErrUserNameIllegal { + if models.IsErrNameReserved(err) || models.IsErrNamePatternNotAllowed(err) { ctx.Data["OrgName"] = true ctx.RenderWithErr(ctx.Tr("form.illegal_username"), tplSettingsOptions, &form) } else { |