diff options
author | Nathan Yergler <nathan@yergler.net> | 2011-10-01 12:08:58 -0700 |
---|---|---|
committer | Nathan Yergler <nathan@yergler.net> | 2011-10-01 12:08:58 -0700 |
commit | 6bfbe0242653678c09258b7a642514d706153eac (patch) | |
tree | d3e0c7f94f566886a6b80ce98d8a003465f4368f /mediagoblin/auth/lib.py | |
parent | 0a8a3fc1571100aba3bd3a3dec98f5e9e252780b (diff) | |
parent | 573aba86b58c2ab064d0d57ed0bbae6bdf9a2819 (diff) | |
download | mediagoblin-6bfbe0242653678c09258b7a642514d706153eac.tar.lz mediagoblin-6bfbe0242653678c09258b7a642514d706153eac.tar.xz mediagoblin-6bfbe0242653678c09258b7a642514d706153eac.zip |
Merge remote-tracking branch 'refs/remotes/upstream/master' into 569-application-middleware
Conflicts:
mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html
Diffstat (limited to 'mediagoblin/auth/lib.py')
-rw-r--r-- | mediagoblin/auth/lib.py | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/mediagoblin/auth/lib.py b/mediagoblin/auth/lib.py index 89cfb6ff..d7d351a5 100644 --- a/mediagoblin/auth/lib.py +++ b/mediagoblin/auth/lib.py @@ -47,7 +47,7 @@ def bcrypt_check_password(raw_pass, stored_hash, extra_salt=None): # number (thx to zooko on this advice, which I hopefully # incorporated right.) # - # See also: + # See also: rand_salt = bcrypt.gensalt(5) randplus_stored_hash = bcrypt.hashpw(stored_hash, rand_salt) randplus_hashed_pass = bcrypt.hashpw(hashed_pass, rand_salt) @@ -99,7 +99,7 @@ def send_verification_email(user, request): Args: - user: a user object - - request: the request + - request: the request """ rendered_email = render_template( request, 'mediagoblin/auth/verification_email.txt', @@ -116,8 +116,38 @@ def send_verification_email(user, request): [user['email']], # TODO # Due to the distributed nature of GNU MediaGoblin, we should - # find a way to send some additional information about the - # specific GNU MediaGoblin instance in the subject line. For - # example "GNU MediaGoblin @ Wandborg - [...]". + # find a way to send some additional information about the + # specific GNU MediaGoblin instance in the subject line. For + # example "GNU MediaGoblin @ Wandborg - [...]". 'GNU MediaGoblin - Verify your email!', rendered_email) + + +EMAIL_FP_VERIFICATION_TEMPLATE = ( + u"http://{host}{uri}?" + u"userid={userid}&token={fp_verification_key}") + +def send_fp_verification_email(user, request): + """ + Send the verification email to users to change their password. + + Args: + - user: a user object + - request: the request + """ + rendered_email = render_template( + request, 'mediagoblin/auth/fp_verification_email.txt', + {'username': user['username'], + 'verification_url': EMAIL_FP_VERIFICATION_TEMPLATE.format( + host=request.host, + uri=request.urlgen('mediagoblin.auth.verify_forgot_password'), + userid=unicode(user['_id']), + fp_verification_key=user['fp_verification_key'])}) + + # TODO: There is no error handling in place + send_email( + mg_globals.app_config['email_sender_address'], + [user['email']], + 'GNU MediaGoblin - Change forgotten password!', + rendered_email) + |