diff options
author | Rodney Ewing <ewing.rj@gmail.com> | 2013-07-08 17:00:37 -0700 |
---|---|---|
committer | Rodney Ewing <ewing.rj@gmail.com> | 2013-08-16 10:28:47 -0700 |
commit | aeae6cc29099c4bea84bbfd006615104ba719b1e (patch) | |
tree | 56a89bf2efa7d47596d95a9644e710d056c4262e /mediagoblin/plugins/basic_auth/tools.py | |
parent | fb900ef27b65b3d220ce16972593869441b4c82c (diff) | |
download | mediagoblin-aeae6cc29099c4bea84bbfd006615104ba719b1e.tar.lz mediagoblin-aeae6cc29099c4bea84bbfd006615104ba719b1e.tar.xz mediagoblin-aeae6cc29099c4bea84bbfd006615104ba719b1e.zip |
moved forgot pass to basic_auth plugin
Diffstat (limited to 'mediagoblin/plugins/basic_auth/tools.py')
-rw-r--r-- | mediagoblin/plugins/basic_auth/tools.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/mediagoblin/plugins/basic_auth/tools.py b/mediagoblin/plugins/basic_auth/tools.py index 1300bb9a..97393976 100644 --- a/mediagoblin/plugins/basic_auth/tools.py +++ b/mediagoblin/plugins/basic_auth/tools.py @@ -82,3 +82,36 @@ def fake_login_attempt(): randplus_hashed_pass = bcrypt.hashpw(hashed_pass, rand_salt) randplus_stored_hash == randplus_hashed_pass + + +EMAIL_FP_VERIFICATION_TEMPLATE = ( + u"{uri}?" + u"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 + """ + fp_verification_key = get_timed_signer_url('mail_verification_token') \ + .dumps(user.id) + + rendered_email = render_template( + request, 'mediagoblin/auth/fp_verification_email.txt', + {'username': user.username, + 'verification_url': EMAIL_FP_VERIFICATION_TEMPLATE.format( + uri=request.urlgen('mediagoblin.auth.verify_forgot_password', + qualified=True), + fp_verification_key=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) + |