Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions models/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"crypto/sha256"
"crypto/subtle"
"encoding/hex"
"errors"
"fmt"
"net/url"
"os"
Expand Down Expand Up @@ -73,11 +72,6 @@ const (
EmailNotificationsDisabled = "disabled"
)

var (
// ErrUserNameIllegal user name contains illegal characters error
ErrUserNameIllegal = errors.New("User name contains illegal characters")
)

// User represents the object of individual and member of organization.
type User struct {
ID int64 `xorm:"pk autoincr"`
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 @@ -73,7 +73,7 @@ func SettingsPost(ctx *context.Context) {
ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), tplSettingsOptions, &form)
return
} else if err = user_model.ChangeUserName(org.AsUser(), form.Name); err != nil {
if err == user_model.ErrUserNameIllegal {
if db.IsErrNameReserved(err) || db.IsErrNamePatternNotAllowed(err) {
ctx.Data["OrgName"] = true
ctx.RenderWithErr(ctx.Tr("form.illegal_username"), tplSettingsOptions, &form)
} else {
Expand Down