mirror of
https://github.com/go-gitea/gitea
synced 2024-11-02 09:45:05 +01:00
fix 500 error while use a reserved name in org rename (#17878)
fix #17876 Signed-off-by: a1012112796 <1012112796@qq.com>
This commit is contained in:
parent
7026a30fdc
commit
ba57e30f13
@ -10,7 +10,6 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"crypto/subtle"
|
"crypto/subtle"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
@ -73,11 +72,6 @@ const (
|
|||||||
EmailNotificationsDisabled = "disabled"
|
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.
|
// User represents the object of individual and member of organization.
|
||||||
type User struct {
|
type User struct {
|
||||||
ID int64 `xorm:"pk autoincr"`
|
ID int64 `xorm:"pk autoincr"`
|
||||||
|
@ -73,7 +73,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 = user_model.ChangeUserName(org.AsUser(), form.Name); err != nil {
|
} 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.Data["OrgName"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("form.illegal_username"), tplSettingsOptions, &form)
|
ctx.RenderWithErr(ctx.Tr("form.illegal_username"), tplSettingsOptions, &form)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user