aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-13 04:06:35 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-13 04:06:35 -0400
commitc01f593daa994dddc208f853c1c116c56d2ea397 (patch)
treedf572e8608c00f2448e19c0b868a38f1f1a30a7a /modules
parent76dae5bf680cd701b1ae9876ecc21486a8721f92 (diff)
Add updatePasswd
Diffstat (limited to 'modules')
-rw-r--r--modules/auth/user.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/modules/auth/user.go b/modules/auth/user.go
index e868fac2..6bc71306 100644
--- a/modules/auth/user.go
+++ b/modules/auth/user.go
@@ -128,3 +128,36 @@ func (f *UpdateProfileForm) Validate(errors *binding.Errors, req *http.Request,
validate(errors, data, f)
}
+
+type UpdatePasswdForm struct {
+ OldPasswd string `form:"oldpasswd" binding:"Required;MinSize(6);MaxSize(30)"`
+ NewPasswd string `form:"newpasswd" binding:"Required;MinSize(6);MaxSize(30)"`
+ RetypePasswd string `form:"retypepasswd"`
+}
+
+func (f *UpdatePasswdForm) Name(field string) string {
+ names := map[string]string{
+ "OldPasswd": "Old password",
+ "NewPasswd": "New password",
+ "RetypePasswd": "Re-type password",
+ }
+ return names[field]
+}
+
+func (f *UpdatePasswdForm) Validate(errors *binding.Errors, 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)
+}