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 authored and Stelios Malathouras committed Mar 28, 2022
1 parent b9edcdb commit b51408a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
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

0 comments on commit b51408a

Please sign in to comment.