From 5333bd7d1473a47c7fea93eb718200069aef3bca Mon Sep 17 00:00:00 2001 From: John Cox Date: Tue, 29 Apr 2014 17:42:08 -0700 Subject: [PATCH] Fix bug that prevented account association during registration --- common/djangoapps/third_party_auth/pipeline.py | 2 +- .../third_party_auth/tests/specs/base.py | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/common/djangoapps/third_party_auth/pipeline.py b/common/djangoapps/third_party_auth/pipeline.py index 3da391c729..241a957483 100644 --- a/common/djangoapps/third_party_auth/pipeline.py +++ b/common/djangoapps/third_party_auth/pipeline.py @@ -350,7 +350,7 @@ def redirect_to_supplementary_form(strategy, details, response, uid, is_dashboar user_inactive = user and not user.is_active user_unset = user is None - dispatch_to_login = (is_login and user_unset) or user_inactive + dispatch_to_login = is_login and (user_unset or user_inactive) if is_dashboard: return diff --git a/common/djangoapps/third_party_auth/tests/specs/base.py b/common/djangoapps/third_party_auth/tests/specs/base.py index d5e2e93ded..c00290a28e 100644 --- a/common/djangoapps/third_party_auth/tests/specs/base.py +++ b/common/djangoapps/third_party_auth/tests/specs/base.py @@ -640,21 +640,17 @@ class IntegrationTest(testutil.TestCase, test.TestCase): created_user = self.get_user_by_email(strategy, email) self.assert_password_overridden_by_pipeline(overridden_password, created_user.username) - # The user's account isn't created yet, so an attempt to complete the - # pipeline will error out on /login: - self.assert_redirect_to_login_looks_correct( - actions.do_complete(strategy, social_views._do_login, user=created_user)) - # So we activate the account in order to verify the redirect to /dashboard: - created_user.is_active = True - created_user.save() + # At this point the user object exists, but there is no associated + # social auth. + self.assert_social_auth_does_not_exist_for_user(created_user, strategy) - # Last step in the pipeline: we re-invoke the pipeline and expect to - # end up on /dashboard, with the correct social auth object now in the - # backend and the correct user's data on display. + # Pick the pipeline back up. This will create the account association + # and send the user to the dashboard, where the association will be + # displayed. self.assert_redirect_to_dashboard_looks_correct( actions.do_complete(strategy, social_views._do_login, user=created_user)) self.assert_social_auth_exists_for_user(created_user, strategy) - self.assert_dashboard_response_looks_correct(student_views.dashboard(request), created_user) + self.assert_dashboard_response_looks_correct(student_views.dashboard(request), created_user, linked=True) def test_new_account_registration_assigns_distinct_username_on_collision(self): original_username = self.get_username()