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/10/15 12:56:11 UTC
[01/12] git commit: [#7704] ticket:662 Added checks for pending status
Repository: allura
Updated Branches:
refs/heads/je/42cc_7704 [created] 40f21b4c5
[#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/1b700cc8
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1b700cc8
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1b700cc8
Branch: refs/heads/je/42cc_7704
Commit: 1b700cc837aef39a9152a9ab2bd461002c1ac735
Parents: bae9adb
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 20:58:28 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Oct 15 11:24:54 2014 +0300
----------------------------------------------------------------------
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/1b700cc8/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/1b700cc8/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index e15e4c0..eb9feef 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()
@@ -364,7 +364,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):
@@ -387,7 +387,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 ''
@@ -514,7 +514,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)
@@ -551,7 +551,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/1b700cc8/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/1b700cc8/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/1b700cc8/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
[10/12] 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/1fdc928a
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1fdc928a
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1fdc928a
Branch: refs/heads/je/42cc_7704
Commit: 1fdc928a262b2cc998ab84d4cb8dc4c4eaf34b1b
Parents: 4e88deb
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Oct 15 11:31:40 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Oct 15 11:31:40 2014 +0300
----------------------------------------------------------------------
Allura/allura/controllers/auth.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/1fdc928a/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index d3a8475..39e728e 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)
[03/12] 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/bae9adb2
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/bae9adb2
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/bae9adb2
Branch: refs/heads/je/42cc_7704
Commit: bae9adb2f3a682b8f40a38f4b8b2f8b1cdd734b9
Parents: 0ca83a6
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 20:45:43 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Oct 15 11:24:54 2014 +0300
----------------------------------------------------------------------
Allura/allura/controllers/auth.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/bae9adb2/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 526fb4d..5900e82 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -266,7 +266,11 @@ class AuthController(BaseController):
})
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')
[06/12] 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/9685b2cd
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/9685b2cd
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/9685b2cd
Branch: refs/heads/je/42cc_7704
Commit: 9685b2cd6b4531a209270eecdba370211c58461c
Parents: 193bede
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Thu Oct 9 15:42:33 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Oct 15 11:24:55 2014 +0300
----------------------------------------------------------------------
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 | 55 ++++++++++++++++++++----
4 files changed, 73 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/9685b2cd/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index c78b980..d3a8475 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('/')
@@ -270,7 +269,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/9685b2cd/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index eb9feef..7264dce 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -183,6 +183,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.
@@ -344,6 +348,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)
@@ -589,6 +598,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/9685b2cd/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/9685b2cd/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 058ae09..da6c652 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -379,8 +379,7 @@ class TestAuth(TestController):
username='aaa',
pw='12345678',
pw2='12345678',
- display_name='Test Me',
- email='test@example.com'))
+ display_name='Test Me'))
r = r.follow()
assert 'User "aaa" registered' in unentity(r.body)
r = self.app.post(
@@ -389,19 +388,58 @@ class TestAuth(TestController):
username='aaa',
pw='12345678',
pw2='12345678',
- display_name='Test Me',
- email='test@example.com'))
+ 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)
+ 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'}):
r = self.app.get('/')
@@ -441,6 +479,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(
[07/12] 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/401e6389
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/401e6389
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/401e6389
Branch: refs/heads/je/42cc_7704
Commit: 401e63890f1006c86b31c9260576b0b3f772bccd
Parents: 1b700cc
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Oct 8 14:49:24 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Oct 15 11:24:55 2014 +0300
----------------------------------------------------------------------
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/401e6389/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 5900e82..7ea7c2a 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -268,9 +268,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/401e6389/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 7e5985b..058ae09 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -393,12 +393,14 @@ 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'}):
@@ -435,6 +437,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',
[11/12] 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/6a170300
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/6a170300
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/6a170300
Branch: refs/heads/je/42cc_7704
Commit: 6a170300cc1f7d5887ea2cda8def673cd76089da
Parents: 1fdc928
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Oct 15 11:47:43 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Oct 15 11:47:43 2014 +0300
----------------------------------------------------------------------
Allura/allura/controllers/auth.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/6a170300/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 39e728e..6d95610 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()
[05/12] 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/193beded
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/193beded
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/193beded
Branch: refs/heads/je/42cc_7704
Commit: 193bedede4e4a4e27312d40652121256bb2997df
Parents: 401e638
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Oct 8 14:58:57 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Oct 15 11:24:55 2014 +0300
----------------------------------------------------------------------
Allura/allura/controllers/auth.py | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/193beded/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 7ea7c2a..c78b980 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -271,7 +271,6 @@ class AuthController(BaseController):
user = addr.claimed_by_user()
if user.pending:
user.pending = False
- user.m.save()
else:
flash('Unknown verification link', 'error')
[02/12] 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/0371ec55
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/0371ec55
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/0371ec55
Branch: refs/heads/je/42cc_7704
Commit: 0371ec55a9eb84fae4f3626c7615659e9e6289ac
Parents: 10472d1
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 16:35:22 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Oct 15 11:24:54 2014 +0300
----------------------------------------------------------------------
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/0371ec55/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 1d26350..ceb1f95 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/0371ec55/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',
[08/12] 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/4e88deba
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/4e88deba
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/4e88deba
Branch: refs/heads/je/42cc_7704
Commit: 4e88deba89023588d370bcc098e9bd879541137d
Parents: 2351871
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Fri Oct 10 00:54:43 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Oct 15 11:24:55 2014 +0300
----------------------------------------------------------------------
Allura/allura/model/auth.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/4e88deba/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 433eac0..7294518 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -651,7 +651,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
[04/12] 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/0ca83a63
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/0ca83a63
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/0ca83a63
Branch: refs/heads/je/42cc_7704
Commit: 0ca83a63bd24b49fe128e7226592bf9eb633703e
Parents: 0371ec5
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 18:57:09 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Oct 15 11:24:54 2014 +0300
----------------------------------------------------------------------
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/0ca83a63/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index ceb1f95..526fb4d 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/0ca83a63/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 32f9b17..f45be91 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -234,6 +234,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/0ca83a63/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 cc6ce56..7e5985b 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -379,7 +379,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(
@@ -388,13 +389,16 @@ 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'}):
@@ -428,7 +432,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] 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/2351871d
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/2351871d
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/2351871d
Branch: refs/heads/je/42cc_7704
Commit: 2351871df0a382efbb64f9e8b7ffd92fe1fac0a8
Parents: 9685b2c
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Fri Oct 10 00:53:26 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Oct 15 11:24:55 2014 +0300
----------------------------------------------------------------------
Allura/allura/model/auth.py | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/2351871d/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index f45be91..433eac0 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -301,6 +301,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
email_addresses_t=' '.join(self.email_addresses),
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'),
[12/12] 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/40f21b4c
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/40f21b4c
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/40f21b4c
Branch: refs/heads/je/42cc_7704
Commit: 40f21b4c589e716d9e45e5b5351ec0317134e7b3
Parents: 6a17030
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Oct 15 11:49:16 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Oct 15 11:49:16 2014 +0300
----------------------------------------------------------------------
Allura/allura/controllers/auth.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/40f21b4c/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 6d95610..68bb0e6 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('/')