From f73f4c4b8425fb49b95a453107e5717caeb38386 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Fri, 29 Jul 2011 08:43:59 -0500 Subject: [PATCH] Log in user after regitration --- mediagoblin/auth/views.py | 6 ++++++ mediagoblin/tests/test_auth.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py index cf07d668..e0d9c8f1 100644 --- a/mediagoblin/auth/views.py +++ b/mediagoblin/auth/views.py @@ -62,8 +62,14 @@ def register(request): request.POST['password']) user.save(validate=True) + # log the user in + request.session['user_id'] = unicode(user['_id']) + request.session.save() + + # send verification email send_verification_email(user, request) + # give the user a message and redirect messages.add_message( request, messages.INFO, diff --git a/mediagoblin/tests/test_auth.py b/mediagoblin/tests/test_auth.py index ccb9a536..f0bb183f 100644 --- a/mediagoblin/tests/test_auth.py +++ b/mediagoblin/tests/test_auth.py @@ -164,6 +164,11 @@ def test_register_views(test_app): assert new_user['status'] == u'needs_email_verification' assert new_user['email_verified'] == False + ## Make sure user is logged in + request = util.TEMPLATE_TEST_CONTEXT[ + 'mediagoblin/user_pages/user.html']['request'] + assert request.session['user_id'] == unicode(new_user['_id']) + ## Make sure we get email confirmation, and try verifying assert len(util.EMAIL_TEST_INBOX) == 1 message = util.EMAIL_TEST_INBOX.pop() -- 2.25.1