fix #981
This commit is contained in:
parent
3fb1b6a608
commit
acf428863c
2 changed files with 11 additions and 4 deletions
|
@ -5,7 +5,10 @@
|
||||||
package org
|
package org
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/Unknwon/com"
|
"github.com/Unknwon/com"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/auth"
|
"github.com/gogits/gogs/modules/auth"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
|
@ -39,7 +42,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateOrgSettingForm) {
|
||||||
org := ctx.Org.Organization
|
org := ctx.Org.Organization
|
||||||
|
|
||||||
// Check if organization name has been changed.
|
// Check if organization name has been changed.
|
||||||
if org.Name != form.Name {
|
if org.LowerName != strings.ToLower(form.Name) {
|
||||||
isExist, err := models.IsUserExist(org.Id, form.Name)
|
isExist, err := models.IsUserExist(org.Id, form.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "IsUserExist", err)
|
ctx.Handle(500, "IsUserExist", err)
|
||||||
|
@ -58,8 +61,10 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateOrgSettingForm) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Trace("Organization name changed: %s -> %s", org.Name, form.Name)
|
log.Trace("Organization name changed: %s -> %s", org.Name, form.Name)
|
||||||
org.Name = form.Name
|
|
||||||
}
|
}
|
||||||
|
// In case it's just a case change.
|
||||||
|
org.Name = form.Name
|
||||||
|
org.LowerName = strings.ToLower(form.Name)
|
||||||
|
|
||||||
org.FullName = form.FullName
|
org.FullName = form.FullName
|
||||||
org.Description = form.Description
|
org.Description = form.Description
|
||||||
|
|
|
@ -49,7 +49,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if user name has been changed.
|
// Check if user name has been changed.
|
||||||
if ctx.User.Name != form.Name {
|
if ctx.User.LowerName != strings.ToLower(form.Name) {
|
||||||
if err := models.ChangeUserName(ctx.User, form.Name); err != nil {
|
if err := models.ChangeUserName(ctx.User, form.Name); err != nil {
|
||||||
switch {
|
switch {
|
||||||
case models.IsErrUserAlreadyExist(err):
|
case models.IsErrUserAlreadyExist(err):
|
||||||
|
@ -70,8 +70,10 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Trace("User name changed: %s -> %s", ctx.User.Name, form.Name)
|
log.Trace("User name changed: %s -> %s", ctx.User.Name, form.Name)
|
||||||
ctx.User.Name = form.Name
|
|
||||||
}
|
}
|
||||||
|
// In case it's just a case change.
|
||||||
|
ctx.User.Name = form.Name
|
||||||
|
ctx.User.LowerName = strings.ToLower(form.Name)
|
||||||
|
|
||||||
ctx.User.FullName = form.FullName
|
ctx.User.FullName = form.FullName
|
||||||
ctx.User.Email = form.Email
|
ctx.User.Email = form.Email
|
||||||
|
|
Loading…
Reference in a new issue