diff options
author | Unknwon <u@gogs.io> | 2015-09-17 17:21:27 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-09-17 17:21:27 -0400 |
commit | acf428863c38d77e6f6ca975702fb4da216b76ea (patch) | |
tree | 66a1cf13628ba379d8c73b6e401802132e696db1 | |
parent | 3fb1b6a608625067a76ba90f9855d48c4d6555bd (diff) | |
download | gitea-acf428863c38d77e6f6ca975702fb4da216b76ea.tar.gz gitea-acf428863c38d77e6f6ca975702fb4da216b76ea.zip |
fix #981
-rw-r--r-- | routers/org/setting.go | 9 | ||||
-rw-r--r-- | routers/user/setting.go | 6 |
2 files changed, 11 insertions, 4 deletions
diff --git a/routers/org/setting.go b/routers/org/setting.go index 9e26afa7d4..bd9ab13be9 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -5,7 +5,10 @@ package org import ( + "strings" + "github.com/Unknwon/com" + "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/base" @@ -39,7 +42,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateOrgSettingForm) { org := ctx.Org.Organization // 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) if err != nil { ctx.Handle(500, "IsUserExist", err) @@ -58,8 +61,10 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateOrgSettingForm) { return } 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.Description = form.Description diff --git a/routers/user/setting.go b/routers/user/setting.go index 9aaedcc426..9be567a487 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -49,7 +49,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) { } // 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 { switch { case models.IsErrUserAlreadyExist(err): @@ -70,8 +70,10 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) { return } 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.Email = form.Email |