summaryrefslogtreecommitdiffstats
path: root/routers/user
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-02-22 18:24:49 -0500
committerUnknwon <u@gogs.io>2015-02-22 18:24:49 -0500
commit04164eada3bc89bb3b54aa3dea0f22203ff4aa6e (patch)
tree8c66bfea48dc2f1fc9638c212477d26fb807a743 /routers/user
parent74a8bb93d84a75fae46cd40f2b670073bee5a593 (diff)
downloadgitea-04164eada3bc89bb3b54aa3dea0f22203ff4aa6e.tar.gz
gitea-04164eada3bc89bb3b54aa3dea0f22203ff4aa6e.zip
models: able to rename user with diff letter cases #981
- templates/org: mirror fix on name output - routers: add missing error check
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/setting.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/routers/user/setting.go b/routers/user/setting.go
index 9398f69a0e..a44d3b7e5d 100644
--- a/routers/user/setting.go
+++ b/routers/user/setting.go
@@ -50,7 +50,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
// Check if user name has been changed.
if ctx.User.Name != form.UserName {
- isExist, err := models.IsUserExist(form.UserName)
+ isExist, err := models.IsUserExist(ctx.User.Id, form.UserName)
if err != nil {
ctx.Handle(500, "IsUserExist", err)
return
@@ -58,11 +58,14 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), SETTINGS_PROFILE, &form)
return
} else if err = models.ChangeUserName(ctx.User, form.UserName); err != nil {
- if err == models.ErrUserNameIllegal {
+ switch err {
+ case models.ErrUserNameIllegal:
ctx.Flash.Error(ctx.Tr("form.illegal_username"))
ctx.Redirect(setting.AppSubUrl + "/user/settings")
- return
- } else {
+ case models.ErrEmailAlreadyUsed:
+ ctx.Flash.Error(ctx.Tr("form.email_been_used"))
+ ctx.Redirect(setting.AppSubUrl + "/user/settings")
+ default:
ctx.Handle(500, "ChangeUserName", err)
}
return