allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [16/27] git commit: [#7657] ticket:651 Autoverify emails if added via site admin UI nad fix audit logs
Date Mon, 29 Sep 2014 16:17:47 GMT
[#7657] ticket:651 Autoverify emails if added via site admin UI nad fix audit logs


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

Branch: refs/heads/db/7657
Commit: 2e86cb1a4ee271e265d782c8aedf788173398561
Parents: 239ad6b
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Sep 16 14:01:00 2014 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Sep 26 16:39:46 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/2e86cb1a/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 0e4b4c4..87908b8 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -233,10 +233,7 @@ class AuthController(BaseController):
             flash('No such address', 'error')
         redirect(request.referer)
 
-    @expose()
-    def verify_addr(self, a):
-        addr = M.EmailAddress.query.get(nonce=a)
-
+    def _verify_addr(self, addr):
         if addr:
             addr.confirmed = True
             # Remove other non-confirmed emails claimed by other users
@@ -256,9 +253,14 @@ class AuthController(BaseController):
             })
 
             flash('Email address confirmed')
-            h.auditlog_user('Email address verified: %s', addr._id)
+            h.auditlog_user('Email address verified: %s', addr._id, user=addr.claimed_by_user())
         else:
             flash('Unknown verification link', 'error')
+
+    @expose()
+    def verify_addr(self, a):
+        addr = M.EmailAddress.query.get(nonce=a)
+        self._verify_addr(addr)
         redirect('/auth/preferences/')
 
     @expose()
@@ -454,7 +456,7 @@ class PreferencesController(BaseController):
                         # clear it now, a new one will get set below
                         user.set_pref('email_address', None)
                         primary_addr = None
-                h.auditlog_user('Email address deleted: %s', user.email_addresses[i])
+                h.auditlog_user('Email address deleted: %s', user.email_addresses[i], user=user)
                 del user.email_addresses[i]
                 if obj:
                     obj.delete()
@@ -469,9 +471,12 @@ class PreferencesController(BaseController):
                 user.email_addresses.append(new_addr['addr'])
                 em = M.EmailAddress.create(new_addr['addr'])
                 em.claimed_by_user_id = user._id
-                em.send_verification_link()
-                h.auditlog_user('New email address: %s', new_addr['addr'])
-                flash('A verification email has been sent.  Please check your email and click
to confirm.')
+                if not admin:
+                    em.send_verification_link()
+                    flash('A verification email has been sent.  Please check your email and
click to confirm.')
+                else:
+                    AuthController()._verify_addr(em)
+                h.auditlog_user('New email address: %s', new_addr['addr'], user=user)
             else:
                 flash('Email address %s is invalid' % new_addr['addr'], 'error')
         if not primary_addr and not user.get_pref('email_address') and user.email_addresses:
@@ -484,7 +489,8 @@ class PreferencesController(BaseController):
                 h.auditlog_user(
                     'Primary email changed: %s => %s',
                     user.get_pref('email_address'),
-                    primary_addr)
+                    primary_addr,
+                    user=user)
             user.set_pref('email_address', primary_addr)
 
     @h.vardec


Mime
View raw message