fix 500 error while use a reserved name in org rename (#17878) (#17881)

fix #17876

Signed-off-by: a1012112796 <1012112796@qq.com>
This commit is contained in:
a1012112796 2021-12-02 19:52:08 +08:00 committed by GitHub
parent d29a0fc3be
commit 9a8532d928
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 4 deletions

View file

@ -77,9 +77,6 @@ var (
// ErrEmailNotActivated e-mail address has not been activated error // ErrEmailNotActivated e-mail address has not been activated error
ErrEmailNotActivated = errors.New("E-mail address has not been activated") 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 login source is not actived error
ErrLoginSourceNotActived = errors.New("Login source is not actived") ErrLoginSourceNotActived = errors.New("Login source is not actived")

View file

@ -65,7 +65,7 @@ func SettingsPost(ctx *context.Context) {
ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), tplSettingsOptions, &form) ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), tplSettingsOptions, &form)
return return
} else if err = models.ChangeUserName(org, form.Name); err != nil { } 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.Data["OrgName"] = true
ctx.RenderWithErr(ctx.Tr("form.illegal_username"), tplSettingsOptions, &form) ctx.RenderWithErr(ctx.Tr("form.illegal_username"), tplSettingsOptions, &form)
} else { } else {