aboutsummaryrefslogtreecommitdiffstats
path: root/routers/org/org.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-03-26 17:11:47 -0400
committerUnknwon <u@gogs.io>2015-03-26 17:11:47 -0400
commit698b9e2acc4daafe7d2b314e2d8c96545dde9c40 (patch)
tree8d593bb0816503494de4deb16ee0fa6b95eb3c5c /routers/org/org.go
parentd76f11c6f14b69bf981e5fc3901cc2c6445773b8 (diff)
downloadgitea-698b9e2acc4daafe7d2b314e2d8c96545dde9c40.tar.gz
gitea-698b9e2acc4daafe7d2b314e2d8c96545dde9c40.zip
#1070 Clearer error message for illegal characters
Diffstat (limited to 'routers/org/org.go')
-rw-r--r--routers/org/org.go17
1 files changed, 10 insertions, 7 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
}