diff options
author | Aleksandar Micovic <aleks.micovic@gmail.com> | 2011-06-02 21:07:37 -0400 |
---|---|---|
committer | Aleksandar Micovic <aleks.micovic@gmail.com> | 2011-06-02 21:07:37 -0400 |
commit | 02d80437d1cdda5b2a8596d024aafa8b286cb360 (patch) | |
tree | 840069ed3f4dc8a3c1e030fff1e7b76b752f17a2 /mediagoblin/auth/views.py | |
parent | 04cb99b22316a9d7d93e30e4748d74d51fa63c85 (diff) | |
download | mediagoblin-02d80437d1cdda5b2a8596d024aafa8b286cb360.tar.lz mediagoblin-02d80437d1cdda5b2a8596d024aafa8b286cb360.tar.xz mediagoblin-02d80437d1cdda5b2a8596d024aafa8b286cb360.zip |
Refactored the sending of verification emails.
Diffstat (limited to 'mediagoblin/auth/views.py')
-rw-r--r-- | mediagoblin/auth/views.py | 50 |
1 files changed, 5 insertions, 45 deletions
diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py index 948db188..e4f1a7b1 100644 --- a/mediagoblin/auth/views.py +++ b/mediagoblin/auth/views.py @@ -21,8 +21,7 @@ from webob import Response, exc from mediagoblin.db.util import ObjectId from mediagoblin.auth import lib as auth_lib from mediagoblin.auth import forms as auth_forms -from mediagoblin.util import send_email -from mediagoblin import globals as mgoblin_globals +from mediagoblin.auth.lib import send_verification_email def register(request): @@ -52,27 +51,8 @@ def register(request): request.POST['password']) entry.save(validate=True) - email_template = request.template_env.get_template( - 'mediagoblin/auth/verification_email.txt') - - # TODO: There is no error handling in place - send_email( - mgoblin_globals.email_sender_address, - [entry['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 - [...]". - 'GNU MediaGoblin - Verify email', - email_template.render( - username=entry['username'], - verification_url='http://{host}{uri}?userid={userid}&token={verification_key}'.format( - host=request.host, - uri=request.urlgen('mediagoblin.auth.verify_email'), - userid=unicode(entry['_id']), - verification_key=entry['verification_key']))) - + send_verification_email(entry, request) + # Redirect to register_success return exc.HTTPFound( location=request.urlgen("mediagoblin.auth.register_success")) @@ -195,31 +175,11 @@ def resend_activation(request): Resend the activation email. """ + request.user['verification_key'] = unicode(uuid.uuid4()) request.user.save() - # Copied shamelessly from the register view above. - - email_template = request.template_env.get_template( - 'mediagoblin/auth/verification_email.txt') - - # TODO: There is no error handling in place - send_email( - mgoblin_globals.email_sender_address, - [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 - [...]". - 'GNU MediaGoblin - Verify email', - email_template.render( - username=request.user['username'], - verification_url='http://{host}{uri}?userid={userid}&token={verification_key}'.format( - host=request.host, - uri=request.urlgen('mediagoblin.auth.verify_email'), - userid=unicode(request.user['_id']), - verification_key=request.user['verification_key']))) + send_verification_email(request.user, request) return exc.HTTPFound( location=request.urlgen('mediagoblin.auth.resend_verification_success')) |