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/10 10:37:27 UTC

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

Repository: allura
Updated Branches:
  refs/heads/ib/7704 [created] 49b62f302


[#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/059dd966
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/059dd966
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/059dd966

Branch: refs/heads/ib/7704
Commit: 059dd966f10104bac17e4d5ebadb9414b86b012d
Parents: 625e2b6
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 16:35:22 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 4 13:48:23 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/059dd966/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/059dd966/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',


[12/12] 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/49b62f30
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/49b62f30
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/49b62f30

Branch: refs/heads/ib/7704
Commit: 49b62f302a586b8540525c1d61e6a6b41f9fdb70
Parents: e1bb376
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Oct 15 11:49:16 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 4 13:57:04 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/49b62f30/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('/')
 


[11/12] 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/e1bb3767
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/e1bb3767
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/e1bb3767

Branch: refs/heads/ib/7704
Commit: e1bb3767ba0ecc2a65addfbfe1fffbd3731b568f
Parents: 2047f61
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Oct 15 11:47:43 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 4 13:57:04 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/e1bb3767/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()


[02/12] 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/5e9fa610
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/5e9fa610
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/5e9fa610

Branch: refs/heads/ib/7704
Commit: 5e9fa6104de398bba9ddc07d85fa581dae6a36aa
Parents: 059dd96
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 18:57:09 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 4 13:52:15 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/5e9fa610/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/5e9fa610/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/5e9fa610/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


[09/12] 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/d15b3348
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/d15b3348
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/d15b3348

Branch: refs/heads/ib/7704
Commit: d15b33484e6a52631ab13e8061ad93d1cf7f8372
Parents: 566f303
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Fri Oct 10 00:53:26 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 4 13:57:03 2014 +0000

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


http://git-wip-us.apache.org/repos/asf/allura/blob/d15b3348/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'),


[03/12] 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/3af20f2f
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/3af20f2f
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/3af20f2f

Branch: refs/heads/ib/7704
Commit: 3af20f2f72e2220b6e860ead7b4efb073e0ebcec
Parents: d43b5c7
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 20:58:28 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 4 13:52:16 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/3af20f2f/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/3af20f2f/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/3af20f2f/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/3af20f2f/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/3af20f2f/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


[05/12] 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/87c509d3
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/87c509d3
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/87c509d3

Branch: refs/heads/ib/7704
Commit: 87c509d3f905543bb124f4862afa174cfc62ca57
Parents: e2bc3cd
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Oct 8 14:58:57 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 4 13:55:04 2014 +0000

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


http://git-wip-us.apache.org/repos/asf/allura/blob/87c509d3/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')
 


[08/12] 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/2047f612
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/2047f612
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/2047f612

Branch: refs/heads/ib/7704
Commit: 2047f612d53828d50862155933c9cc5c1717d404
Parents: f8447a3
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Oct 15 11:31:40 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 4 13:57:03 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/2047f612/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)


[06/12] 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/e2bc3cd4
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/e2bc3cd4
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/e2bc3cd4

Branch: refs/heads/ib/7704
Commit: e2bc3cd4379aa847393a0053cae12e0f5fa9bcba
Parents: 3af20f2
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Oct 8 14:49:24 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 4 13:55: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/e2bc3cd4/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/e2bc3cd4/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',


[10/12] 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/f8447a3f
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/f8447a3f
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/f8447a3f

Branch: refs/heads/ib/7704
Commit: f8447a3f9cb7dc2a83212a3498fcb10ae8aad0f7
Parents: d15b334
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Fri Oct 10 00:54:43 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 4 13:57:03 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/f8447a3f/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


[07/12] 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/566f3038
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/566f3038
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/566f3038

Branch: refs/heads/ib/7704
Commit: 566f3038f99f5a5e0547679a7ae29808dfaa0c9a
Parents: 87c509d
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Thu Oct 9 15:42:33 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 4 13:57:02 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/566f3038/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/566f3038/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/566f3038/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/566f3038/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(


[04/12] 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/d43b5c71
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/d43b5c71
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/d43b5c71

Branch: refs/heads/ib/7704
Commit: d43b5c71152c79ce89c069f7f5ac630a6cc97abe
Parents: 5e9fa61
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 20:45:43 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 4 13:52:16 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/d43b5c71/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')