Skip to content

Commit

Permalink
Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
cslzchen committed Sep 21, 2016
1 parent e3a4137 commit 30ed520
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
18 changes: 10 additions & 8 deletions framework/auth/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ def get_user(email=None, password=None, token=None, external_id_provider=None, e
1. email
2. email and password
3 token
4. oauth_provider and oauth_id
4. external_id_provider and external_id
:param token: the token in verification key
:param email: user's email
:param password: user's password
:param external_id_provider: the oauth provider
:param external_id: the oauth id
:param external_id_provider: the external identity provider
:param external_id: the external id
:rtype User or None
"""

Expand Down Expand Up @@ -294,14 +294,14 @@ class User(GuidStoredObject, AddonModelMixin):
is_invited = fields.BooleanField(default=False, index=True)

# Per-project unclaimed user data:
# TODO: add a validation function that ensures that all required keys are present in the input values for that field
# TODO: add validation
unclaimed_records = fields.DictionaryField(required=False)
# Format: {
# <project_id>: {
# 'name': <name that referrer provided>,
# 'referrer_id': <user ID of referrer>,
# 'token': <verification key v1, used for verification urls>,
# 'expires': <expiration time for this record>,
# 'token': <verification token>,
# 'expires': <verification expiration time>,
# 'email': <email the referrer provided or None>,
# 'claimer_email': <email the claimer entered or None>,
# 'last_sent': <timestamp of last email sent to referrer or None>
Expand All @@ -322,13 +322,15 @@ class User(GuidStoredObject, AddonModelMixin):
merged_by = fields.ForeignField('user', default=None, index=True)

# verification key v1: only the token string, no expiration time
# used for cas login with username and verification key
verification_key = fields.StringField()

# verification key v2: token, and expiration time
# used for password reset, confirm account/email, claim account/contributor-ship
verification_key_v2 = fields.DictionaryField(default=dict)
# Format: {
# 'token': <the verification key string>
# 'expires': <the expiration time for the key>
# 'token': <verification token>
# 'expires': <verification expiration time>
# }

email_last_sent = fields.DateTimeField()
Expand Down
4 changes: 2 additions & 2 deletions tests/webtest_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ def setUp(self):
self.user.verification_key_v2 = {}
self.user.save()

# log user out before land on forgot password page
# log users out before they land on forgot password page
def test_forgot_password_logs_out_user(self):
# visit forgot password link while another user is logged in
res = self.app.get(self.get_url, auth=self.auth_user.auth)
Expand Down Expand Up @@ -1072,7 +1072,7 @@ def test_can_reset_password_if_form_success(self, mock_service_validate):
cas.make_response_from_ticket(ticket, service_url)
assert_equal(self.user.verification_key, None)

# log user out before land on reset password page
# log users out before they land on reset password page
def test_reset_password_logs_out_user(self):
# visit reset password link while another user is logged in
res = self.app.get(self.get_url, auth=self.another_user.auth)
Expand Down
4 changes: 2 additions & 2 deletions website/project/views/contributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,10 @@ def claim_user_post(node, **kwargs):
claimer = get_user(email=email)
# registered user
if claimer and claimer.is_registered:
send_claim_registered_email(claimer=claimer, unclaimed_user=unclaimed_user, node=node)
send_claim_registered_email(claimer, unclaimed_user, node)
# unregistered user
else:
send_claim_email(email=email, unclaimed_user=unclaimed_user, node=node, notify=True)
send_claim_email(email, unclaimed_user, node, notify=True)
# Claimer is logged in with confirmed identity stored in `request_data['claimerId']`
elif 'claimerId' in request_data:
claimer_id = request_data['claimerId']
Expand Down
2 changes: 1 addition & 1 deletion website/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def parent_dir(path):
EXPIRATION_TIME_DICT = {
'password': 30, # 30 minutes for forgot and reset password
'confirm': 24 * 60, # 24 hours in minutes for confirm account and email
'claim': 7 * 24 * 60 # 7 days in minutes for claim contributor-ship
'claim': 30 * 24 * 60 # 30 days in minutes for claim contributor-ship
}

CITATION_STYLES_PATH = os.path.join(BASE_PATH, 'static', 'vendor', 'bower_components', 'styles')
Expand Down

0 comments on commit 30ed520

Please sign in to comment.