Dot-Notation for Users.fp_verification_key

This commit is contained in:
Elrond 2011-11-14 19:21:33 +01:00
parent 4b77f86ab4
commit dc39e4555c
3 changed files with 6 additions and 6 deletions

View File

@ -145,7 +145,7 @@ def send_fp_verification_email(user, request):
host=request.host,
uri=request.urlgen('mediagoblin.auth.verify_forgot_password'),
userid=unicode(user._id),
fp_verification_key=user['fp_verification_key'])})
fp_verification_key=user.fp_verification_key)})
# TODO: There is no error handling in place
send_email(

View File

@ -250,7 +250,7 @@ def forgot_password(request):
if user:
if user.email_verified and user.status == 'active':
user[u'fp_verification_key'] = unicode(uuid.uuid4())
user.fp_verification_key = unicode(uuid.uuid4())
user[u'fp_token_expire'] = datetime.datetime.now() + \
datetime.timedelta(days=10)
user.save()
@ -301,8 +301,8 @@ def verify_forgot_password(request):
return render_404(request)
# check if we have a real user and correct token
if ((user and user['fp_verification_key'] and
user['fp_verification_key'] == unicode(formdata_token) and
if ((user and user.fp_verification_key and
user.fp_verification_key == unicode(formdata_token) and
datetime.datetime.now() < user['fp_token_expire']
and user.email_verified and user.status == 'active')):
@ -311,7 +311,7 @@ def verify_forgot_password(request):
if request.method == 'POST' and cp_form.validate():
user.pw_hash = auth_lib.bcrypt_gen_password_hash(
request.POST['password'])
user[u'fp_verification_key'] = None
user.fp_verification_key = None
user[u'fp_token_expire'] = None
user.save()

View File

@ -270,7 +270,7 @@ def test_register_views(test_app):
# user should have matching parameters
new_user = mg_globals.database.User.find_one({'username': 'happygirl'})
assert parsed_get_params['userid'] == [unicode(new_user._id)]
assert parsed_get_params['token'] == [new_user['fp_verification_key']]
assert parsed_get_params['token'] == [new_user.fp_verification_key]
### The forgotten password token should be set to expire in ~ 10 days
# A few ticks have expired so there are only 9 full days left...