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/12 13:15:04 UTC

[01/17] allura git commit: Change tracker links to forge-allura.apache.org

Repository: allura
Updated Branches:
  refs/heads/ib/7704 49b62f302 -> 3a959f00d (forced update)


Change tracker links to forge-allura.apache.org


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

Branch: refs/heads/ib/7704
Commit: e9c2d07de7650c7a72d2d4e26d753f8bfaa1c25a
Parents: 625e2b6
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Nov 5 15:00:42 2014 +0200
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 5 15:00:42 2014 +0200

----------------------------------------------------------------------
 CONTRIBUTING     | 2 +-
 INSTALL.markdown | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/e9c2d07d/CONTRIBUTING
----------------------------------------------------------------------
diff --git a/CONTRIBUTING b/CONTRIBUTING
index 0c70739..88ae8ce 100644
--- a/CONTRIBUTING
+++ b/CONTRIBUTING
@@ -52,7 +52,7 @@ list and an IRC channel.
 
 Report bugs to our public tracker at:
 
-  <https://sourceforge.net/p/allura/tickets/>
+  <https://forge-allura.apache.org/p/allura/tickets/>
 
 Four things make for a good bug report:
 

http://git-wip-us.apache.org/repos/asf/allura/blob/e9c2d07d/INSTALL.markdown
----------------------------------------------------------------------
diff --git a/INSTALL.markdown b/INSTALL.markdown
index b5e984c..cbee9a3 100644
--- a/INSTALL.markdown
+++ b/INSTALL.markdown
@@ -123,7 +123,7 @@ The default configuration stores repos in `/srv`, so we need to create those dir
 
 If you don't have `sudo` permission or just want to store them somewhere else, change the `/srv` paths in `development.ini`
 
-If you want to set up remote access to the repositories, see <http://allura.sourceforge.net/docs/scm_host.html>
+If you want to set up remote access to the repositories, see <http://forge-allura.apache.org/docs/scm_host.html>
 
 ### Allura task processing
 
@@ -155,9 +155,9 @@ register a new project in your own forge, visit /p/add_project
 
 ## Extra
 
-* Read more documentation: <http://allura.sourceforge.net/docs/>
-    * Including how to enable extra features: <http://allura.sourceforge.net/docs/installation.html>
+* Read more documentation: <http://forge-allura.apache.org/docs/>
+    * Including how to enable extra features: <http://forge-allura.apache.org/docs/installation.html>
 * Ask questions and discuss Allura on the <http://mail-archives.apache.org/mod_mbox/allura-dev/>
 * Run the test suite (slow): `$ ALLURA_VALIDATION=none ./run_tests`
-* File bug reports at <https://sourceforge.net/p/allura/tickets/new/> (login required)
+* File bug reports at <https://forge-allura.apache.org/p/allura/tickets/new/> (login required)
 * Contribute code according to this guide: <https://forge-allura.apache.org/p/allura/wiki/Contributing%20Code/>


[08/17] allura git commit: [#7704] ticket:662 Fixed user saving

Posted by je...@apache.org.
[#7704] ticket:662 Fixed user saving


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

Branch: refs/heads/ib/7704
Commit: 258e7d4391b3e50db5e19a665aae1310620683f7
Parents: 2d8143b
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Oct 8 14:58:57 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 12 10:27:04 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/258e7d43/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index c66b12e..b9e3d3b 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -264,7 +264,6 @@ class AuthController(BaseController):
             user = addr.claimed_by_user()
             if user.pending:
                 user.pending = False
-                user.m.save()
         else:
             flash('Unknown verification link', 'error')
 


[16/17] allura git commit: [#7704] ticket:683 Check for pending users in claimed_by_user

Posted by je...@apache.org.
[#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 <je...@gmail.com>
Authored: Wed Nov 12 11:05:04 2014 +0000
Committer: Igor Bondarenko <je...@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,


[09/17] allura git commit: [#7704] ticket:662 Fixed tests

Posted by je...@apache.org.
[#7704] ticket:662 Fixed tests


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

Branch: refs/heads/ib/7704
Commit: 2d8143b085d62d6101699c747f17e535ee3bbe1d
Parents: 6184868
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Oct 8 14:49:24 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 12 10:27:04 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py           | 7 ++++---
 Allura/allura/tests/functional/test_auth.py | 8 ++++++--
 2 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/2d8143b0/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index cec2b28..c66b12e 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -261,9 +261,10 @@ class AuthController(BaseController):
             flash('Email address confirmed')
             h.auditlog_user('Email address verified: %s',  addr.email, user=addr.claimed_by_user())
 
-            if addr.claimed_by_user.pending:
-                addr.claimed_by_user.pending = False
-                addr.claimed_by_user.m.save()
+            user = addr.claimed_by_user()
+            if user.pending:
+                user.pending = False
+                user.m.save()
         else:
             flash('Unknown verification link', 'error')
 

http://git-wip-us.apache.org/repos/asf/allura/blob/2d8143b0/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index 4a2b52b..3a50b7c 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -550,11 +550,13 @@ class TestAuth(TestController):
                               email='test@example.com'))
         assert 'That username is already taken. Please choose another.' in r
         r = self.app.get('/auth/logout')
+        user = M.User.query.get(username='aaa')
+        assert user.pending
+        user.pending = False
+        session(user).flush(user)
         r = self.app.post('/auth/do_login',
                           params=dict(username='aaa', password='12345678'),
                           status=302)
-        user = M.User.query.get(username='aaa')
-        assert user.pending
 
     def test_create_account_disabled_header_link(self):
         with h.push_config(config, **{'auth.allow_user_registration': 'false'}):
@@ -589,6 +591,8 @@ class TestAuth(TestController):
             display_name='Test Me',
             email='test@example.com')).follow()
         user = M.User.query.get(username='aaa')
+        user.pending = False
+        session(user).flush(user)
         assert M.ProjectRole.query.find(
             dict(user_id=user._id, project_id=p._id)).count() == 0
         self.app.get('/p/test/admin/permissions',


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

Posted by je...@apache.org.
[#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/61848689
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/61848689
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/61848689

Branch: refs/heads/ib/7704
Commit: 61848689ce2f877af6f3a512268c9b527fdd59d9
Parents: e997f03
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 20:58:28 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 12 10:27:03 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/61848689/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/61848689/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/61848689/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/61848689/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/61848689/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


[04/17] allura git commit: [#7704] ticket:662 Set pending status on registration

Posted by je...@apache.org.
[#7704] ticket:662 Set pending status on registration


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

Branch: refs/heads/ib/7704
Commit: 88aa3f19320a826dbf6006f85de0eacf9e1ea31e
Parents: 1428182
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 18:57:09 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 12 10:27:03 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py           |  3 ++-
 Allura/allura/model/auth.py                 |  1 +
 Allura/allura/tests/functional/test_auth.py | 11 ++++++++---
 3 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/88aa3f19/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index e3798f1..5d966a1 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -227,7 +227,8 @@ class AuthController(BaseController):
             dict(username=username,
                  display_name=display_name,
                  password=pw,
-                 email_addresses=[email]))
+                 email_addresses=[email],
+                 pending=True))
         plugin.AuthenticationProvider.get(request).login(user)
         em = M.EmailAddress.create(email)
         em.claimed_by_user_id = user._id

http://git-wip-us.apache.org/repos/asf/allura/blob/88aa3f19/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 74fcd24..ee2793b 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -248,6 +248,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
     tool_preferences = FieldProperty(S.Deprecated)
     tool_data = FieldProperty({str: {str: None}})  # entry point: prefs dict
     disabled = FieldProperty(bool, if_missing=False)
+    pending = FieldProperty(bool, if_missing=False)
 
     # Don't use these directly, use get/set_pref() instead
     preferences = FieldProperty(dict(

http://git-wip-us.apache.org/repos/asf/allura/blob/88aa3f19/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index add0a16..4a2b52b 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -537,7 +537,8 @@ class TestAuth(TestController):
                               username='aaa',
                               pw='12345678',
                               pw2='12345678',
-                              display_name='Test Me'))
+                              display_name='Test Me',
+                              email='test@example.com'))
         r = r.follow()
         assert 'User "aaa" registered' in unentity(r.body)
         r = self.app.post('/auth/save_new',
@@ -545,12 +546,15 @@ class TestAuth(TestController):
                               username='aaa',
                               pw='12345678',
                               pw2='12345678',
-                              display_name='Test Me'))
+                              display_name='Test Me',
+                              email='test@example.com'))
         assert 'That username is already taken. Please choose another.' in r
         r = self.app.get('/auth/logout')
         r = self.app.post('/auth/do_login',
                           params=dict(username='aaa', password='12345678'),
                           status=302)
+        user = M.User.query.get(username='aaa')
+        assert user.pending
 
     def test_create_account_disabled_header_link(self):
         with h.push_config(config, **{'auth.allow_user_registration': 'false'}):
@@ -582,7 +586,8 @@ class TestAuth(TestController):
             username='aaa',
             pw='12345678',
             pw2='12345678',
-            display_name='Test Me')).follow()
+            display_name='Test Me',
+            email='test@example.com')).follow()
         user = M.User.query.get(username='aaa')
         assert M.ProjectRole.query.find(
             dict(user_id=user._id, project_id=p._id)).count() == 0


[17/17] allura git commit: [#7704] ticket:683 Add migration to set user.pending to False

Posted by je...@apache.org.
[#7704] ticket:683 Add migration to set user.pending to False


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

Branch: refs/heads/ib/7704
Commit: 3a959f00d31ea33dd913658053a2827f2b6e3b5b
Parents: 6e4d5ba
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Nov 12 11:28:40 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 12 11:28:40 2014 +0000

----------------------------------------------------------------------
 .../migrations/031-set-user-pending-to-false.py | 39 ++++++++++++++++++++
 1 file changed, 39 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/3a959f00/scripts/migrations/031-set-user-pending-to-false.py
----------------------------------------------------------------------
diff --git a/scripts/migrations/031-set-user-pending-to-false.py b/scripts/migrations/031-set-user-pending-to-false.py
new file mode 100644
index 0000000..02d35d9
--- /dev/null
+++ b/scripts/migrations/031-set-user-pending-to-false.py
@@ -0,0 +1,39 @@
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you under the Apache License, Version 2.0 (the
+#       "License"); you may not use this file except in compliance
+#       with the License.  You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing,
+#       software distributed under the License is distributed on an
+#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#       KIND, either express or implied.  See the License for the
+#       specific language governing permissions and limitations
+#       under the License.
+
+import logging
+
+from ming.odm import ThreadLocalORMSession, state
+
+from allura.lib import utils
+from allura import model as M
+
+log = logging.getLogger(__name__)
+
+
+def main():
+    for chunk in utils.chunked_find(M.User):
+        for user in chunk:
+            print 'Processing {0}'.format(user.username)
+            user.pending = False
+            # Ming doesn't mark document for update, since pending is False
+            # by default, even if field is missing from mongo
+            state(user).status = state(user).dirty
+            ThreadLocalORMSession.flush_all()
+
+if __name__ == '__main__':
+    main()


[13/17] allura git commit: [#7704] ticket:662 Mention verification email in flash message

Posted by je...@apache.org.
[#7704] ticket:662 Mention verification email in flash message


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

Branch: refs/heads/ib/7704
Commit: 691b74f8bb9af6b7affa298c946e9e5cf34f711b
Parents: f0b6736
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Oct 15 11:47:43 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 12 10:27:05 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/691b74f8/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 875ebeb..35d8207 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -233,7 +233,9 @@ class AuthController(BaseController):
         if require_email:
             em = user.claim_address(email)
             em.send_verification_link()
-        flash('User "%s" registered' % username)
+            flash('User "%s" registered. Verification link was sent to your email.' % username)
+        else:
+            flash('User "%s" registered' % username)
         redirect('/')
 
     @expose()


[07/17] allura git commit: [#7704] ticket:662 Added pending field to index

Posted by je...@apache.org.
[#7704] ticket:662 Added pending field to index


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

Branch: refs/heads/ib/7704
Commit: 80f0f2c1c31bb7fb507b5686688c05930a20b6e1
Parents: b27e5ec
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Fri Oct 10 00:53:26 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 12 10:27:04 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/80f0f2c1/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index ee2793b..96a9795 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -315,6 +315,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
             email_addresses_t=' '.join([e for e in self.email_addresses if e]),
             last_password_updated_dt=self.last_password_updated,
             disabled_b=self.disabled,
+            pending_b=self.pending,
             results_per_page_i=self.get_pref('results_per_page'),
             email_address_s=self.get_pref('email_address'),
             email_format_s=self.get_pref('email_format'),


[02/17] allura git commit: [#7793] ticket:679 Limit extraneous fieldset styling

Posted by je...@apache.org.
[#7793] ticket:679 Limit extraneous fieldset styling


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

Branch: refs/heads/ib/7704
Commit: 9151524934ad87150118bb5242c096ca2db09331
Parents: e9c2d07
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Nov 10 10:10:25 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon Nov 10 10:10:25 2014 +0000

----------------------------------------------------------------------
 Allura/allura/nf/allura/css/site_style.css           |  4 ++--
 Allura/allura/templates/site_admin_user_details.html | 10 +++++-----
 Allura/allura/templates/user_prefs.html              | 12 ++++++------
 3 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/91515249/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index 963f071..93692f6 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -3498,7 +3498,7 @@ ul.dropdown ul li a:hover {
 }
 .strikethrough { text-decoration: line-through; }
 
-fieldset {
+fieldset.preferences {
   margin-bottom: 2em;
   border: 1px solid silver;
   padding: 8px;
@@ -3506,7 +3506,7 @@ fieldset {
   -moz-border-radius: 4px;
   border-radius: 4px;
 }
-legend {
+fieldset.preferences legend {
   margin: .2em;
   padding: .2em;
   font-size: 1.5em;

http://git-wip-us.apache.org/repos/asf/allura/blob/91515249/Allura/allura/templates/site_admin_user_details.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_user_details.html b/Allura/allura/templates/site_admin_user_details.html
index 0666b5c..8f18d7e 100644
--- a/Allura/allura/templates/site_admin_user_details.html
+++ b/Allura/allura/templates/site_admin_user_details.html
@@ -28,7 +28,7 @@
 
   {% block general_info %}
     <div class="grid-23">
-      <fieldset>
+      <fieldset class="preferences">
         <legend>General</legend>
         <div class="grid-16">
         <ul>
@@ -67,7 +67,7 @@
 
   {% block emails %}
     <div class="grid-23">
-      <fieldset>
+      <fieldset class="preferences">
         <legend>Emails</legend>
         <form action="update_emails" method="post">
           {% include 'allura:templates/update_emails_form.html' %}
@@ -79,7 +79,7 @@
 
   {% block session_info %}
     <div class="grid-23">
-      <fieldset>
+      <fieldset class="preferences">
         <legend>Session</legend>
         <h3>Last login</h3>
         <ul>
@@ -103,7 +103,7 @@
   {% block audit_log %}
     <div class="grid-23">
       {% set al = audit_log %}
-      <fieldset>
+      <fieldset class="preferences">
         <legend>Audit log</legend>
         <form action='/nf/admin/user/add_audit_trail_entry' method='POST'>
           <div class='grid-22'>
@@ -127,7 +127,7 @@
 
   {% block user_projects %}
     <div class="grid-23">
-      <fieldset>
+      <fieldset class="preferences">
         <legend>Projects</legend>
         <ul>
           {% for p in projects %}

http://git-wip-us.apache.org/repos/asf/allura/blob/91515249/Allura/allura/templates/user_prefs.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/user_prefs.html b/Allura/allura/templates/user_prefs.html
index bc8cf42..bd593ab 100644
--- a/Allura/allura/templates/user_prefs.html
+++ b/Allura/allura/templates/user_prefs.html
@@ -29,7 +29,7 @@
   <div class="grid-23">
     <h2>Preferences</h2>
     {% block info %}
-    <fieldset>
+    <fieldset class="preferences">
       <legend>Username: {{ c.user.username }}</legend>
       <p><a href="{{ c.user.private_project().url() }}">My profile and my projects</a></p>
       <p><a href="{{ c.user.private_project().url() }}admin/overview">Set avatar icon</a></p>
@@ -41,7 +41,7 @@
 
     {% block edit_prefs_form %}
       {% if h.asbool(tg.config.get('auth.allow_edit_prefs', True)) %}
-        <fieldset>
+        <fieldset class="preferences">
           <legend>General Settings</legend>
           <form action="update" method="POST">
             <label class="grid-4">Display Name</label>
@@ -64,7 +64,7 @@
           </form>
         </fieldset>
 
-        <fieldset>
+        <fieldset class="preferences">
           <legend>Email addresses</legend>
           <form action="update_emails" method="post" name="update-email">
             {% include 'allura:templates/update_emails_form.html' %}
@@ -93,7 +93,7 @@
 
     {% block password_change_form %}
       {% if h.asbool(tg.config.get('auth.allow_password_change', True)) %}
-        <fieldset>
+        <fieldset class="preferences">
           <legend>Change Password</legend>
           {{ c.password_change_form.display() }}
         </fieldset>
@@ -102,7 +102,7 @@
 
     {% block upload_key_form %}
       {% if h.asbool(tg.config.get('auth.allow_upload_ssh_key', False)) %}
-        <fieldset>
+        <fieldset class="preferences">
           <legend>Upload ssh public key</legend>
           {{ c.upload_key_form.display() }}
         </fieldset>
@@ -111,7 +111,7 @@
 
     {% block user_messages_form %}
       {% if h.asbool(tg.config.get('auth.allow_user_messages_config', True)) %}
-        <fieldset>
+        <fieldset class="preferences">
           <legend>User Messages</legend>
           <form method="POST" action="user_message">
           <div class="grid-10">


[14/17] allura git commit: [#7704] ticket:662 Don't try to log in if user isn't active after registration

Posted by je...@apache.org.
[#7704] ticket:662 Don't try to log in if user isn't active after registration


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

Branch: refs/heads/ib/7704
Commit: 418a18b501e19579e9f2e4760f9497e73c3a8d6e
Parents: 691b74f
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Oct 15 11:49:16 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 12 10:27:05 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/418a18b5/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 35d8207..489bacc 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -229,12 +229,12 @@ class AuthController(BaseController):
                  display_name=display_name,
                  password=pw,
                  pending=require_email))
-        plugin.AuthenticationProvider.get(request).login(user)
         if require_email:
             em = user.claim_address(email)
             em.send_verification_link()
             flash('User "%s" registered. Verification link was sent to your email.' % username)
         else:
+            plugin.AuthenticationProvider.get(request).login(user)
             flash('User "%s" registered' % username)
         redirect('/')
 


[03/17] allura git commit: [#7704] ticket:662 Clear pending status on confirming an email address

Posted by je...@apache.org.
[#7704] ticket:662 Clear pending status on confirming an email address


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

Branch: refs/heads/ib/7704
Commit: e997f030f0418086dd883fc7d1368cf2938bc857
Parents: 88aa3f1
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 20:45:43 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 12 10:27:03 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/e997f030/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 5d966a1..cec2b28 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -259,7 +259,11 @@ class AuthController(BaseController):
         if addr and not confirmed_by_other:
             addr.confirmed = True
             flash('Email address confirmed')
-            h.auditlog_user('Email address verified: %s', addr.email, user=addr.claimed_by_user())
+            h.auditlog_user('Email address verified: %s',  addr.email, user=addr.claimed_by_user())
+
+            if addr.claimed_by_user.pending:
+                addr.claimed_by_user.pending = False
+                addr.claimed_by_user.m.save()
         else:
             flash('Unknown verification link', 'error')
 


[12/17] allura git commit: [#7704] ticket:662 Claim email only if option is set

Posted by je...@apache.org.
[#7704] ticket:662 Claim email only if option is set


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

Branch: refs/heads/ib/7704
Commit: f0b6736741beb75f1c1a11926f576bafb0f3a9b3
Parents: 16d7f36
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Oct 15 11:31:40 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 12 10:27:05 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/f0b67367/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 4076b14..875ebeb 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -223,13 +223,14 @@ class AuthController(BaseController):
     def save_new(self, display_name=None, username=None, pw=None, email=None, **kw):
         if not asbool(config.get('auth.allow_user_registration', True)):
             raise wexc.HTTPNotFound()
+        require_email = asbool(config.get('auth.require_email_addr', False))
         user = M.User.register(
             dict(username=username,
                  display_name=display_name,
                  password=pw,
-                 pending=asbool(config.get('auth.require_email_addr', False))))
+                 pending=require_email))
         plugin.AuthenticationProvider.get(request).login(user)
-        if email is not None:
+        if require_email:
             em = user.claim_address(email)
             em.send_verification_link()
         flash('User "%s" registered' % username)


[05/17] allura git commit: [#7704] ticket:662 Added email field to registration form

Posted by je...@apache.org.
[#7704] ticket:662 Added email field to registration form


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

Branch: refs/heads/ib/7704
Commit: 14281829d1757785c970ad6b5cf28445a573ec21
Parents: 9151524
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 16:35:22 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 12 10:27:03 2014 +0000

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


http://git-wip-us.apache.org/repos/asf/allura/blob/14281829/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 94a97cc..e3798f1 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -220,14 +220,18 @@ class AuthController(BaseController):
     @expose()
     @require_post()
     @validate(F.registration_form, error_handler=create_account)
-    def save_new(self, display_name=None, username=None, pw=None, **kw):
+    def save_new(self, display_name=None, username=None, pw=None, email=None, **kw):
         if not asbool(config.get('auth.allow_user_registration', True)):
             raise wexc.HTTPNotFound()
         user = M.User.register(
             dict(username=username,
                  display_name=display_name,
-                 password=pw))
+                 password=pw,
+                 email_addresses=[email]))
         plugin.AuthenticationProvider.get(request).login(user)
+        em = M.EmailAddress.create(email)
+        em.claimed_by_user_id = user._id
+        em.send_verification_link()
         flash('User "%s" registered' % username)
         redirect('/')
 

http://git-wip-us.apache.org/repos/asf/allura/blob/14281829/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 89535fb..3d243e2 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -755,6 +755,10 @@ class RegistrationForm(ForgeForm):
                 label='Displayed Name',
                 validator=fev.UnicodeString(not_empty=True)),
             username,
+            ew.TextField(
+                name='email',
+                label='Your e-mail',
+                validator=fev.Email()),
             ew.PasswordField(
                 name='pw',
                 label='New Password',


[10/17] allura git commit: [#7704] ticket:662 Moved user activation to auth plugin, extended tests

Posted by je...@apache.org.
[#7704] ticket:662 Moved user activation to auth plugin, extended tests


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

Branch: refs/heads/ib/7704
Commit: b27e5ec807301d5a02ea0cabb6d65df09ae88873
Parents: 258e7d4
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Thu Oct 9 15:42:33 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 12 10:27:04 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py           | 11 ++--
 Allura/allura/lib/plugin.py                 | 12 ++++
 Allura/allura/lib/widgets/forms.py          | 13 ++--
 Allura/allura/tests/functional/test_auth.py | 84 ++++++++++++++++++------
 4 files changed, 89 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b27e5ec8/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index b9e3d3b..4076b14 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -227,12 +227,11 @@ class AuthController(BaseController):
             dict(username=username,
                  display_name=display_name,
                  password=pw,
-                 email_addresses=[email],
-                 pending=True))
+                 pending=asbool(config.get('auth.require_email_addr', False))))
         plugin.AuthenticationProvider.get(request).login(user)
-        em = M.EmailAddress.create(email)
-        em.claimed_by_user_id = user._id
-        em.send_verification_link()
+        if email is not None:
+            em = user.claim_address(email)
+            em.send_verification_link()
         flash('User "%s" registered' % username)
         redirect('/')
 
@@ -263,7 +262,7 @@ class AuthController(BaseController):
 
             user = addr.claimed_by_user()
             if user.pending:
-                user.pending = False
+                plugin.AuthenticationProvider.get(request).activate_user(user)
         else:
             flash('Unknown verification link', 'error')
 

http://git-wip-us.apache.org/repos/asf/allura/blob/b27e5ec8/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 82284f2..6389360 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -189,6 +189,10 @@ class AuthenticationProvider(object):
         '''Enable user account'''
         raise NotImplementedError, 'enable_user'
 
+    def activate_user(self, user):
+        '''Activate user after registration'''
+        raise NotImplementedError, 'activate_user'
+
     def by_username(self, username):
         '''
         Find a user by username.
@@ -350,6 +354,11 @@ class LocalAuthenticationProvider(AuthenticationProvider):
         session(user).flush(user)
         h.auditlog_user(u'Account enabled', user=user)
 
+    def activate_user(self, user):
+        user.pending = False
+        session(user).flush(user)
+        h.auditlog_user('Account activated', user=user)
+
     def validate_password(self, user, password):
         return self._validate_password(user, password)
 
@@ -601,6 +610,9 @@ class LdapAuthenticationProvider(AuthenticationProvider):
     def enable_user(self, user):
         return LocalAuthenticationProvider(None).enable_user(user)
 
+    def activate_user(self, user):
+        return LocalAuthenticationProvider(None).activate_user(user)
+
     def get_last_password_updated(self, user):
         return LocalAuthenticationProvider(None).get_last_password_updated(user)
 

http://git-wip-us.apache.org/repos/asf/allura/blob/b27e5ec8/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 3d243e2..6f23e40 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -27,6 +27,7 @@ import ew.jinja2_ew as ew
 from pytz import common_timezones, country_timezones, country_names
 from paste.deploy.converters import aslist, asint, asbool
 import tg
+from tg import config
 
 from allura.lib import validators as V
 from allura.lib import helpers as h
@@ -749,16 +750,19 @@ class RegistrationForm(ForgeForm):
             'Usernames must include only letters, numbers, and dashes.'
             ' They must also start with a letter and be at least 3 characters'
             ' long.')
-        return [
+        fields = [
             ew.TextField(
                 name='display_name',
                 label='Displayed Name',
                 validator=fev.UnicodeString(not_empty=True)),
             username,
-            ew.TextField(
+        ]
+        if asbool(config.get('auth.require_email_addr', False)):
+            fields.append(ew.TextField(
                 name='email',
                 label='Your e-mail',
-                validator=fev.Email()),
+                validator=fev.Email(not_empty=True)))
+        fields += [
             ew.PasswordField(
                 name='pw',
                 label='New Password',
@@ -766,11 +770,12 @@ class RegistrationForm(ForgeForm):
                     not_empty=True,
                     min=asint(tg.config.get('auth.min_password_len', 6)),
                     max=asint(tg.config.get('auth.max_password_len', 30)))),
-             ew.PasswordField(
+            ew.PasswordField(
                 name='pw2',
                 label='New Password (again)',
                 validator=fev.UnicodeString(not_empty=True)),
         ]
+        return fields
 
     @ew_core.core.validator
     def to_python(self, value, state):

http://git-wip-us.apache.org/repos/asf/allura/blob/b27e5ec8/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index 3a50b7c..2206f37 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -532,31 +532,72 @@ class TestAuth(TestController):
         r = self.app.post('/auth/save_new',
                           params=dict(username='aaa', pw='123'))
         assert 'Enter a value 6 characters long or more' in r
-        r = self.app.post('/auth/save_new',
-                          params=dict(
-                              username='aaa',
-                              pw='12345678',
-                              pw2='12345678',
-                              display_name='Test Me',
-                              email='test@example.com'))
+        r = self.app.post(
+            '/auth/save_new',
+            params=dict(
+                username='aaa',
+                pw='12345678',
+                pw2='12345678',
+                display_name='Test Me'))
         r = r.follow()
         assert 'User "aaa" registered' in unentity(r.body)
-        r = self.app.post('/auth/save_new',
-                          params=dict(
-                              username='aaa',
-                              pw='12345678',
-                              pw2='12345678',
-                              display_name='Test Me',
-                              email='test@example.com'))
+        r = self.app.post(
+            '/auth/save_new',
+            params=dict(
+                username='aaa',
+                pw='12345678',
+                pw2='12345678',
+                display_name='Test Me'))
         assert 'That username is already taken. Please choose another.' in r
         r = self.app.get('/auth/logout')
-        user = M.User.query.get(username='aaa')
-        assert user.pending
-        user.pending = False
-        session(user).flush(user)
-        r = self.app.post('/auth/do_login',
-                          params=dict(username='aaa', password='12345678'),
-                          status=302)
+        r = self.app.post(
+            '/auth/do_login',
+            params=dict(username='aaa', password='12345678'),
+            status=302)
+
+    def test_create_account_require_email(self):
+        with h.push_config(config, **{'auth.require_email_addr': 'false'}):
+            self.app.post(
+                '/auth/save_new',
+                params=dict(
+                    username='aaa',
+                    pw='12345678',
+                    pw2='12345678',
+                    display_name='Test Me',
+                    email='test@example.com'))
+            user = M.User.query.get(username='aaa')
+            assert not user.pending
+        with h.push_config(config, **{'auth.require_email_addr': 'true'}):
+            self.app.post(
+                '/auth/save_new',
+                params=dict(
+                    username='bbb',
+                    pw='12345678',
+                    pw2='12345678',
+                    display_name='Test Me',
+                    email='test@example.com'))
+            user = M.User.query.get(username='bbb')
+            assert user.pending
+
+    def test_verify_email(self):
+        with h.push_config(config, **{'auth.require_email_addr': 'true'}):
+            r = self.app.post(
+                '/auth/save_new',
+                params=dict(
+                    username='aaa',
+                    pw='12345678',
+                    pw2='12345678',
+                    display_name='Test Me',
+                    email='test@example.com'))
+            r = r.follow()
+            user = M.User.query.get(username='aaa')
+            em = M.EmailAddress.query.get(email='test@example.com')
+            assert user._id == em.claimed_by_user_id
+            r = self.app.get('/auth/verify_addr', params=dict(a=em.nonce))
+            user = M.User.query.get(username='aaa')
+            em = M.EmailAddress.query.get(email='test@example.com')
+            assert not user.pending
+            assert em.confirmed
 
     def test_create_account_disabled_header_link(self):
         with h.push_config(config, **{'auth.allow_user_registration': 'false'}):
@@ -595,6 +636,7 @@ class TestAuth(TestController):
         session(user).flush(user)
         assert M.ProjectRole.query.find(
             dict(user_id=user._id, project_id=p._id)).count() == 0
+
         self.app.get('/p/test/admin/permissions',
                      extra_environ=dict(username='aaa'), status=403)
         assert M.ProjectRole.query.find(


[15/17] allura git commit: [#7704] ticket:683 Update log message

Posted by je...@apache.org.
[#7704] ticket:683 Update log message


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

Branch: refs/heads/ib/7704
Commit: af4548accd35f59c15ef73a812f2a863cd9a9a7e
Parents: 418a18b
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Nov 12 10:29:29 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 12 10:29:29 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/af4548ac/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 6389360..c0dbf51 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -569,7 +569,7 @@ class LdapAuthenticationProvider(AuthenticationProvider):
                 log.debug('LdapAuth: no user {} found in local mongo'.format(username))
                 raise exc.HTTPUnauthorized()
         elif user.disabled or user.pending:
-            log.debug('LdapAuth: user {} is disabled in Allura'.format(username))
+            log.debug('LdapAuth: user {} is disabled or pending in Allura'.format(username))
             raise exc.HTTPUnauthorized()
         return user
 


[11/17] allura git commit: [#7704] ticket:662 Check for pending status in User.private_project

Posted by je...@apache.org.
[#7704] ticket:662 Check for pending status in User.private_project


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

Branch: refs/heads/ib/7704
Commit: 16d7f3616360e36a289423a8092f13a220277ba9
Parents: 80f0f2c
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Fri Oct 10 00:54:43 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 12 10:27:05 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/16d7f361/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 96a9795..ea07999 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -669,7 +669,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
         '''
         Returns the personal user-project for the user
         '''
-        if self.disabled:
+        if self.disabled or self.pending:
             return None
 
         from allura import model as M