diff options
author | Unknwon <u@gogs.io> | 2015-10-29 21:09:48 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-10-29 21:09:48 -0400 |
commit | 7d72c8333e05b377d42fb773ef2d952c8ec87d32 (patch) | |
tree | 0390d83b543b791ad54a40343e2ae76758eebffc /modules/auth | |
parent | 706b0f72e2e4bc91bdbed38fee609cabe9f44e43 (diff) | |
download | gitea-7d72c8333e05b377d42fb773ef2d952c8ec87d32.tar.gz gitea-7d72c8333e05b377d42fb773ef2d952c8ec87d32.zip |
work on #470 and fix miror JS issue when choose targets on compare and pull
Diffstat (limited to 'modules/auth')
-rw-r--r-- | modules/auth/auth.go | 14 | ||||
-rw-r--r-- | modules/auth/user_form.go | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/modules/auth/auth.go b/modules/auth/auth.go index f144899b3c..2e4c80c55e 100644 --- a/modules/auth/auth.go +++ b/modules/auth/auth.go @@ -181,7 +181,7 @@ func AssignForm(form interface{}, data map[string]interface{}) { } } -func getSize(field reflect.StructField, prefix string) string { +func getRuleBody(field reflect.StructField, prefix string) string { for _, rule := range strings.Split(field.Tag.Get("binding"), ";") { if strings.HasPrefix(rule, prefix) { return rule[len(prefix) : len(rule)-1] @@ -191,15 +191,19 @@ func getSize(field reflect.StructField, prefix string) string { } func GetSize(field reflect.StructField) string { - return getSize(field, "Size(") + return getRuleBody(field, "Size(") } func GetMinSize(field reflect.StructField) string { - return getSize(field, "MinSize(") + return getRuleBody(field, "MinSize(") } func GetMaxSize(field reflect.StructField) string { - return getSize(field, "MaxSize(") + return getRuleBody(field, "MaxSize(") +} + +func GetInclude(field reflect.StructField) string { + return getRuleBody(field, "Include(") } // FIXME: struct contains a struct @@ -260,6 +264,8 @@ func validate(errs binding.Errors, data map[string]interface{}, f Form, l macaro data["ErrorMsg"] = trName + l.Tr("form.email_error") case binding.ERR_URL: data["ErrorMsg"] = trName + l.Tr("form.url_error") + case binding.ERR_INCLUDE: + data["ErrorMsg"] = trName + l.Tr("form.include_error", GetInclude(field)) default: data["ErrorMsg"] = l.Tr("form.unknown_error") + " " + errs[0].Classification } diff --git a/modules/auth/user_form.go b/modules/auth/user_form.go index 88d6dd9fba..80af8e72d8 100644 --- a/modules/auth/user_form.go +++ b/modules/auth/user_form.go @@ -44,7 +44,7 @@ type InstallForm struct { AdminName string `binding:"OmitEmpty;AlphaDashDot;MaxSize(30)" locale:"install.admin_name"` AdminPasswd string `binding:"OmitEmpty;MaxSize(255)" locale:"install.admin_password"` AdminConfirmPasswd string - AdminEmail string `binding:"OmitEmpty;Email;MaxSize(50)" locale:"install.admin_email"` + AdminEmail string `binding:"OmitEmpty;MinSize(3);MaxSize(50);Include(@)" locale:"install.admin_email"` } func (f *InstallForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { |