Skip to content

Commit ba57e30

Browse files
authored
fix 500 error while use a reserved name in org rename (#17878)
fix #17876 Signed-off-by: a1012112796 <[email protected]>
1 parent 7026a30 commit ba57e30

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

models/user/user.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"crypto/sha256"
1111
"crypto/subtle"
1212
"encoding/hex"
13-
"errors"
1413
"fmt"
1514
"net/url"
1615
"os"
@@ -73,11 +72,6 @@ const (
7372
EmailNotificationsDisabled = "disabled"
7473
)
7574

76-
var (
77-
// ErrUserNameIllegal user name contains illegal characters error
78-
ErrUserNameIllegal = errors.New("User name contains illegal characters")
79-
)
80-
8175
// User represents the object of individual and member of organization.
8276
type User struct {
8377
ID int64 `xorm:"pk autoincr"`

routers/web/org/setting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func SettingsPost(ctx *context.Context) {
7373
ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), tplSettingsOptions, &form)
7474
return
7575
} else if err = user_model.ChangeUserName(org.AsUser(), form.Name); err != nil {
76-
if err == user_model.ErrUserNameIllegal {
76+
if db.IsErrNameReserved(err) || db.IsErrNamePatternNotAllowed(err) {
7777
ctx.Data["OrgName"] = true
7878
ctx.RenderWithErr(ctx.Tr("form.illegal_username"), tplSettingsOptions, &form)
7979
} else {

0 commit comments

Comments
 (0)