Skip to content

Commit

Permalink
fix 500 error while use a reserved name in org rename (go-gitea#17878)
Browse files Browse the repository at this point in the history
fix go-gitea#17876

Signed-off-by: a1012112796 <1012112796@qq.com>
  • Loading branch information
a1012112796 committed Dec 2, 2021
1 parent d29a0fc commit ca54588
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
3 changes: 0 additions & 3 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion routers/web/org/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ca54588

Please sign in to comment.