allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [16/17] allura git commit: [#7704] ticket:683 Check for pending users in claimed_by_user
Date Wed, 12 Nov 2014 12:15:19 GMT
[#7704] ticket:683 Check for pending users in claimed_by_user


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

Branch: refs/heads/ib/7704
Commit: 6e4d5ba0d8b17ac0364fb59375bdf52b633c1ca6
Parents: af4548a
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed Nov 12 11:05:04 2014 +0000
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Wed Nov 12 11:05:04 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py |  5 ++---
 Allura/allura/lib/mail_util.py    |  4 ++--
 Allura/allura/model/auth.py       | 13 ++++++++++---
 3 files changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/6e4d5ba0/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 489bacc..ef7935f 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -260,10 +260,9 @@ class AuthController(BaseController):
 
         if addr and not confirmed_by_other:
             addr.confirmed = True
+            user = addr.claimed_by_user(include_pending=True)
             flash('Email address confirmed')
-            h.auditlog_user('Email address verified: %s',  addr.email, user=addr.claimed_by_user())
-
-            user = addr.claimed_by_user()
+            h.auditlog_user('Email address verified: %s',  addr.email, user=user)
             if user.pending:
                 plugin.AuthenticationProvider.get(request).activate_user(user)
         else:

http://git-wip-us.apache.org/repos/asf/allura/blob/6e4d5ba0/Allura/allura/lib/mail_util.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/mail_util.py b/Allura/allura/lib/mail_util.py
index 20fc411..5181889 100644
--- a/Allura/allura/lib/mail_util.py
+++ b/Allura/allura/lib/mail_util.py
@@ -161,13 +161,13 @@ def identify_sender(peer, email_address, headers, msg):
     addr = M.EmailAddress.query.get(
         email=M.EmailAddress.canonical(email_address), confirmed=True)
     if addr and addr.claimed_by_user_id:
-        return addr.claimed_by_user()
+        return addr.claimed_by_user() or M.User.anonymous()
     from_address = headers.get('From', '').strip()
     if not from_address:
         return M.User.anonymous()
     addr = M.EmailAddress.query.get(email=M.EmailAddress.canonical(from_address))
     if addr and addr.claimed_by_user_id:
-        return addr.claimed_by_user()
+        return addr.claimed_by_user() or M.User.anonymous()
     return M.User.anonymous()
 
 

http://git-wip-us.apache.org/repos/asf/allura/blob/6e4d5ba0/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index ea07999..7928796 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -122,8 +122,13 @@ class EmailAddress(MappedClass):
     confirmed = FieldProperty(bool, if_missing=False)
     nonce = FieldProperty(str)
 
-    def claimed_by_user(self):
-        return User.query.get(_id=self.claimed_by_user_id, disabled=False)
+    def claimed_by_user(self, include_pending=False):
+        q = {'_id': self.claimed_by_user_id,
+             'disabled': False,
+             'pending': False}
+        if include_pending:
+            q.pop('pending', None)
+        return User.query.get(**q)
 
     @classmethod
     def create(cls, addr):
@@ -168,7 +173,9 @@ To verify the email address %s belongs to the user %s,
 please visit the following URL:
 
 %s
-''' % (self.email, self.claimed_by_user().username, g.url('/auth/verify_addr', a=self.nonce))
+''' % (self.email,
+       self.claimed_by_user(include_pending=True).username,
+       g.url('/auth/verify_addr', a=self.nonce))
         log.info('Verification email:\n%s', text)
         allura.tasks.mail_tasks.sendsimplemail.post(
             fromaddr=g.noreply,


Mime
View raw message