diff options
author | Unknwon <u@gogs.io> | 2015-03-26 17:11:47 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-03-26 17:11:47 -0400 |
commit | 698b9e2acc4daafe7d2b314e2d8c96545dde9c40 (patch) | |
tree | 8d593bb0816503494de4deb16ee0fa6b95eb3c5c /routers/org | |
parent | d76f11c6f14b69bf981e5fc3901cc2c6445773b8 (diff) | |
download | gitea-698b9e2acc4daafe7d2b314e2d8c96545dde9c40.tar.gz gitea-698b9e2acc4daafe7d2b314e2d8c96545dde9c40.zip |
#1070 Clearer error message for illegal characters
Diffstat (limited to 'routers/org')
-rw-r--r-- | routers/org/org.go | 17 | ||||
-rw-r--r-- | routers/org/setting.go | 2 |
2 files changed, 11 insertions, 8 deletions
diff --git a/routers/org/org.go b/routers/org/org.go index ab589832d1..ed4f2abdea 100644 --- a/routers/org/org.go +++ b/routers/org/org.go @@ -65,19 +65,22 @@ func CreatePost(ctx *middleware.Context, form auth.CreateOrgForm) { } var err error - if org, err = models.CreateOrganization(org, ctx.User); err != nil { - switch err { - case models.ErrUserAlreadyExist: + if err = models.CreateOrganization(org, ctx.User); err != nil { + switch { + case models.IsErrUserAlreadyExist(err): ctx.Data["Err_OrgName"] = true ctx.RenderWithErr(ctx.Tr("form.org_name_been_taken"), CREATE, &form) - case models.ErrEmailAlreadyUsed: + case models.IsErrEmailAlreadyUsed(err): ctx.Data["Err_Email"] = true ctx.RenderWithErr(ctx.Tr("form.email_been_used"), CREATE, &form) - case models.ErrUserNameIllegal: + case models.IsErrNameReserved(err): ctx.Data["Err_OrgName"] = true - ctx.RenderWithErr(ctx.Tr("form.illegal_org_name"), CREATE, &form) + ctx.RenderWithErr(ctx.Tr("org.form.name_reserved", err.(models.ErrNameReserved).Name), CREATE, &form) + case models.IsErrNamePatternNotAllowed(err): + ctx.Data["Err_OrgName"] = true + ctx.RenderWithErr(ctx.Tr("org.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), CREATE, &form) default: - ctx.Handle(500, "CreateUser", err) + ctx.Handle(500, "CreateOrganization", err) } return } diff --git a/routers/org/setting.go b/routers/org/setting.go index 8bc6a2a96a..7a76199502 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -68,7 +68,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateOrgSettingForm) { org.Avatar = base.EncodeMd5(form.Avatar) org.AvatarEmail = form.Avatar if err := models.UpdateUser(org); err != nil { - if err == models.ErrEmailAlreadyUsed { + if models.IsErrEmailAlreadyUsed(err) { ctx.Data["Err_Email"] = true ctx.RenderWithErr(ctx.Tr("form.email_been_used"), SETTINGS_OPTIONS, &form) } else { |