allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [08/14] git commit: [#6783] ticket:463 fixed validator
Date Thu, 07 Nov 2013 21:07:21 GMT
[#6783] ticket:463 fixed validator


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/6f769e73
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/6f769e73
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/6f769e73

Branch: refs/heads/master
Commit: 6f769e733c3b7ede30f22593fa3afd4a57684e1e
Parents: 7bee93b
Author: coldmind <sokandpal@yandex.ru>
Authored: Thu Oct 31 14:52:02 2013 +0200
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Thu Nov 7 21:05:04 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py  |  6 +++---
 Allura/allura/lib/widgets/forms.py | 10 +++++++---
 2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6f769e73/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 42a9420..06f9307 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -157,6 +157,7 @@ class AuthController(BaseController):
         return dict()
 
     @expose('jinja:allura:templates/forgotten_password.html')
+    @validate(F.recover_password_change_form, error_handler=index)
     def forgotten_password(self, hash=None, **kw):
         provider = plugin.AuthenticationProvider.get(request)
         if not provider:
@@ -174,8 +175,7 @@ class AuthController(BaseController):
                 flash('Hash time was expired.')
                 redirect('/')
             if request.method == 'POST':
-                ap = plugin.AuthenticationProvider.get(request)
-                ap.set_password(user_record, None, kw['pw'])
+                provider.set_password(user_record, None, kw['pw'])
                 user_record.set_tool_data('AuthPasswordReset', hash='', hash_expiry='')
                 flash('Password changed')
                 redirect('/auth/')
@@ -187,7 +187,7 @@ class AuthController(BaseController):
     def password_recovery_hash(self, email=None, **kw):
         if not email:
             redirect('/')
-        user_record = M.User.query.find({'preferences.email_address': email}).first()
+        user_record = M.User.by_email_address(email)
         hash = h.nonce(42)
         user_record.set_tool_data('AuthPasswordReset',
                                   hash=hash,

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6f769e73/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 91dd070..300c934 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -135,14 +135,18 @@ class PasswordChangeBase(ForgeForm):
     @ew_core.core.validator
     def to_python(self, value, state):
         d = super(PasswordChangeBase, self).to_python(value, state)
-        if d['pw'] != d['pw2']:
-            raise formencode.Invalid('Passwords must match', value, state)
+        try:
+            if d['pw'] != d['pw2']:
+                raise formencode.Invalid('Passwords must match', value, state)
+        except KeyError:
+            pass
         return d
 
 class PasswordChangeForm(PasswordChangeBase):
     class fields(ew_core.NameList):
         oldpw = ew.PasswordField(
-            label='Old Password', validator=fev.UnicodeString(not_empty=True))
+            label='Old Password',
+            validator=fev.UnicodeString(not_empty=True))
         pw = ew.PasswordField(
             label='New Password',
             validator=fev.UnicodeString(not_empty=True, min=6))


Mime
View raw message