diff options
author | Unknown <joe2010xtmf@163.com> | 2014-05-05 16:21:43 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-05-05 16:21:43 -0400 |
commit | bbdfe2576966210cfffc830bfbe3731bcf653b3b (patch) | |
tree | bc0fc83c71887270c4f38d53be8383985ffd01c5 /modules/auth/user.go | |
parent | c1eb4d894a092aed1b87ddf5f80ee824fd56789d (diff) | |
download | gitea-bbdfe2576966210cfffc830bfbe3731bcf653b3b.tar.gz gitea-bbdfe2576966210cfffc830bfbe3731bcf653b3b.zip |
User code clean and ui improve
Diffstat (limited to 'modules/auth/user.go')
-rw-r--r-- | modules/auth/user.go | 40 |
1 files changed, 7 insertions, 33 deletions
diff --git a/modules/auth/user.go b/modules/auth/user.go index 0e591398c0..bc3216fe36 100644 --- a/modules/auth/user.go +++ b/modules/auth/user.go @@ -78,7 +78,7 @@ type UpdateProfileForm struct { UserName string `form:"username" binding:"Required;AlphaDash;MaxSize(30)"` FullName string `form:"fullname" binding:"MaxSize(40)"` Email string `form:"email" binding:"Required;Email;MaxSize(50)"` - Website string `form:"website" binding:"MaxSize(50)"` + Website string `form:"website" binding:"Url;MaxSize(50)"` Location string `form:"location" binding:"MaxSize(50)"` Avatar string `form:"avatar" binding:"Required;Email;MaxSize(50)"` } @@ -94,22 +94,9 @@ func (f *UpdateProfileForm) Name(field string) string { return names[field] } -func (f *UpdateProfileForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) { - if req.Method == "GET" || errors.Count() == 0 { - return - } - - data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData) - data["HasError"] = true - - if len(errors.Overall) > 0 { - for _, err := range errors.Overall { - log.Error("UpdateProfileForm.Validate: %v", err) - } - return - } - - validate(errors, data, f) +func (f *UpdateProfileForm) Validate(errs *binding.BindingErrors, req *http.Request, ctx martini.Context) { + data := ctx.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData) + validate(errs, data, f) } type UpdatePasswdForm struct { @@ -127,20 +114,7 @@ func (f *UpdatePasswdForm) Name(field string) string { return names[field] } -func (f *UpdatePasswdForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) { - if req.Method == "GET" || errors.Count() == 0 { - return - } - - data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData) - data["HasError"] = true - - if len(errors.Overall) > 0 { - for _, err := range errors.Overall { - log.Error("UpdatePasswdForm.Validate: %v", err) - } - return - } - - validate(errors, data, f) +func (f *UpdatePasswdForm) Validate(errs *binding.BindingErrors, req *http.Request, ctx martini.Context) { + data := ctx.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData) + validate(errs, data, f) } |