Log in user after regitration
authorChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 29 Jul 2011 13:43:59 +0000 (08:43 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 29 Jul 2011 13:43:59 +0000 (08:43 -0500)
mediagoblin/auth/views.py
mediagoblin/tests/test_auth.py

index cf07d668d90e1b65aef6cad50fe5a94c82d8a1b2..e0d9c8f1b207262d78a65442f7582e1479821a2e 100644 (file)
@@ -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,
index ccb9a5366ee2b2bb7b1af6e019d101b04ff88b07..f0bb183fe5e5d6e3e9c52a3fcf6445a65e8395ac 100644 (file)
@@ -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()