You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2014/11/19 15:01:15 UTC

[04/26] allura git commit: [#7704] ticket:662 Added checks for pending status

[#7704] ticket:662 Added checks for pending status


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

Branch: refs/heads/ib/7794
Commit: 221bded2ed6c33142d5501adc44ddd62ccc81674
Parents: a175f3e
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 20:58:28 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:02 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/project.py |  5 +++--
 Allura/allura/lib/plugin.py          | 10 +++++-----
 Allura/allura/model/notification.py  |  4 ++--
 Allura/allura/model/project.py       |  2 +-
 Allura/allura/tasks/mail_tasks.py    |  8 ++++----
 5 files changed, 15 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/221bded2/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 2267dcf..8f2b2ef 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -101,7 +101,7 @@ class NeighborhoodController(object):
                 shortname=self.prefix + pname, neighborhood_id=self.neighborhood._id)
         if project is None and self.prefix == 'u/':
             # create user-project if it is missing
-            user = M.User.query.get(username=pname, disabled=False)
+            user = M.User.query.get(username=pname, disabled=False, pending=False)
             if user:
                 project = self.neighborhood.register_project(
                     plugin.AuthenticationProvider.get(
@@ -115,7 +115,7 @@ class NeighborhoodController(object):
         if project and self.prefix == 'u/':
             # make sure user-projects are associated with an enabled user
             user = project.user_project_of
-            if not user or user.disabled:
+            if not user or user.disabled or user.pending:
                 raise exc.HTTPNotFound
         if project.database_configured == False:
             if remainder == ('user_icon',):
@@ -455,6 +455,7 @@ class ProjectController(FeedController):
             '_id': {'$in': named_roles.userids_that_reach},
             'display_name': re.compile(r'(?i)%s' % re.escape(term)),
             'disabled': False,
+            'pending': False,
         }).sort('username').limit(10).all()
         return dict(
             users=[

http://git-wip-us.apache.org/repos/asf/allura/blob/221bded2/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index a2a57b1..82284f2 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -103,7 +103,7 @@ class AuthenticationProvider(object):
 
         if user is None:
             return M.User.anonymous()
-        if user.disabled:
+        if user.disabled or user.pending:
             self.logout()
             return M.User.anonymous()
 
@@ -370,7 +370,7 @@ class LocalAuthenticationProvider(AuthenticationProvider):
         un = un.replace(r'\_', '[-_]')
         un = un.replace(r'\-', '[-_]')
         rex = re.compile('^' + un + '$')
-        return M.User.query.get(username=rex, disabled=False)
+        return M.User.query.get(username=rex, disabled=False, pending=False)
 
     def set_password(self, user, old_password, new_password):
         if old_password is not None and not self.validate_password(user, old_password):
@@ -393,7 +393,7 @@ class LocalAuthenticationProvider(AuthenticationProvider):
 
     def user_by_project_shortname(self, shortname):
         from allura import model as M
-        return M.User.query.get(username=shortname, disabled=False)
+        return M.User.query.get(username=shortname, disabled=False, pending=False)
 
     def update_notifications(self, user):
         return ''
@@ -522,7 +522,7 @@ class LdapAuthenticationProvider(AuthenticationProvider):
 
     def by_username(self, username):
         from allura import model as M
-        return M.User.query.get(username=username, disabled=False)
+        return M.User.query.get(username=username, disabled=False, pending=False)
 
     def set_password(self, user, old_password, new_password):
         dn = ldap_user_dn(user.username)
@@ -559,7 +559,7 @@ class LdapAuthenticationProvider(AuthenticationProvider):
             else:
                 log.debug('LdapAuth: no user {} found in local mongo'.format(username))
                 raise exc.HTTPUnauthorized()
-        elif user.disabled:
+        elif user.disabled or user.pending:
             log.debug('LdapAuth: user {} is disabled in Allura'.format(username))
             raise exc.HTTPUnauthorized()
         return user

http://git-wip-us.apache.org/repos/asf/allura/blob/221bded2/Allura/allura/model/notification.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py
index ad27f5f..8c82890 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -277,7 +277,7 @@ class Notification(MappedClass):
             text=(self.text or '') + self.footer(toaddr))
 
     def send_direct(self, user_id):
-        user = User.query.get(_id=ObjectId(user_id), disabled=False)
+        user = User.query.get(_id=ObjectId(user_id), disabled=False, pending=False)
         artifact = self.ref.artifact
         log.debug('Sending direct notification %s to user %s',
                   self._id, user_id)
@@ -313,7 +313,7 @@ class Notification(MappedClass):
                     reply_to_address=None):
         if not notifications:
             return
-        user = User.query.get(_id=ObjectId(user_id), disabled=False)
+        user = User.query.get(_id=ObjectId(user_id), disabled=False, pending=False)
         if not user:
             log.debug("Skipping notification - enabled user %s not found " %
                       user_id)

http://git-wip-us.apache.org/repos/asf/allura/blob/221bded2/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index f164b4e..42e8e8d 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -857,7 +857,7 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
             g.credentials.project_roles(project_id=self.root_project._id).named)
         uids = [
             uid for uid in named_roles.userids_that_reach if uid is not None]
-        return list(User.query.find({'_id': {'$in': uids}, 'disabled': False}))
+        return list(User.query.find({'_id': {'$in': uids}, 'disabled': False, 'pending': False}))
 
     def users_with_role(self, *role_names):
         """Return all users in this project that have at least one of the roles

http://git-wip-us.apache.org/repos/asf/allura/blob/221bded2/Allura/allura/tasks/mail_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/mail_tasks.py b/Allura/allura/tasks/mail_tasks.py
index 663c690..92c06e7 100644
--- a/Allura/allura/tasks/mail_tasks.py
+++ b/Allura/allura/tasks/mail_tasks.py
@@ -100,7 +100,7 @@ def sendmail(fromaddr, destinations, text, reply_to, subject,
         fromaddr = g.noreply
     elif not isinstance(fromaddr, basestring) or '@' not in fromaddr:
         log.warning('Looking up user with fromaddr: %s', fromaddr)
-        user = M.User.query.get(_id=ObjectId(fromaddr), disabled=False)
+        user = M.User.query.get(_id=ObjectId(fromaddr), disabled=False, pending=False)
         if not user:
             log.warning('Cannot find user with ID: %s', fromaddr)
             fromaddr = g.noreply
@@ -112,7 +112,7 @@ def sendmail(fromaddr, destinations, text, reply_to, subject,
             addrs_plain.append(addr)
         else:
             try:
-                user = M.User.query.get(_id=ObjectId(addr), disabled=False)
+                user = M.User.query.get(_id=ObjectId(addr), disabled=False, pending=False)
                 if not user:
                     log.warning('Cannot find user with ID: %s', addr)
                     continue
@@ -177,7 +177,7 @@ def sendsimplemail(
         fromaddr = g.noreply
     elif not isinstance(fromaddr, basestring) or '@' not in fromaddr:
         log.warning('Looking up user with fromaddr: %s', fromaddr)
-        user = M.User.query.get(_id=ObjectId(fromaddr), disabled=False)
+        user = M.User.query.get(_id=ObjectId(fromaddr), disabled=False, pending=False)
         if not user:
             log.warning('Cannot find user with ID: %s', fromaddr)
             fromaddr = g.noreply
@@ -186,7 +186,7 @@ def sendsimplemail(
 
     if not isinstance(toaddr, basestring) or '@' not in toaddr:
         log.warning('Looking up user with toaddr: %s', toaddr)
-        user = M.User.query.get(_id=ObjectId(toaddr), disabled=False)
+        user = M.User.query.get(_id=ObjectId(toaddr), disabled=False, pending=False)
         if not user:
             log.warning('Cannot find user with ID: %s', toaddr)
             toaddr = g.noreply