From 2fb1a0625acefbdc4ecba6be6fa4e1770d3ab666 Mon Sep 17 00:00:00 2001 From: Arunmozhi Date: Mon, 13 Nov 2023 22:08:24 +0530 Subject: [PATCH] fix: remove re-linking from authenticate_user function --- lms/djangoapps/lti_provider/tests/test_users.py | 9 --------- lms/djangoapps/lti_provider/users.py | 9 --------- 2 files changed, 18 deletions(-) diff --git a/lms/djangoapps/lti_provider/tests/test_users.py b/lms/djangoapps/lti_provider/tests/test_users.py index 9b344ef4859e..1d19d8995be9 100644 --- a/lms/djangoapps/lti_provider/tests/test_users.py +++ b/lms/djangoapps/lti_provider/tests/test_users.py @@ -158,15 +158,6 @@ def test_auto_linking_of_users_using_lis_person_contact_email_primary(self, crea users.authenticate_lti_user(request, self.lti_user_id, self.auto_linking_consumer) create_user.assert_called_with(self.lti_user_id, self.auto_linking_consumer, self.old_user.email) - def test_switch_the_associated_edx_user_when_auto_linking_existing_user(self, create_user, switch_user): - lti_user = self.create_lti_user_model(self.auto_linking_consumer) - new_user = UserFactory.create() - request = RequestFactory().post("/", {"lis_person_contact_email_primary": new_user.email}) - request.user = new_user - - users.authenticate_lti_user(request, self.lti_user_id, self.auto_linking_consumer) - assert LtiUser.objects.get(id=lti_user.id).edx_user == new_user - def test_raise_exception_trying_to_auto_link_unauthenticate_user(self, create_user, switch_user): request = RequestFactory().post("/") request.user = AnonymousUser() diff --git a/lms/djangoapps/lti_provider/users.py b/lms/djangoapps/lti_provider/users.py index 57bb9ca0a148..c2373522b960 100644 --- a/lms/djangoapps/lti_provider/users.py +++ b/lms/djangoapps/lti_provider/users.py @@ -48,15 +48,6 @@ def authenticate_lti_user(request, lti_user_id, lti_consumer): else: lti_user = create_lti_user(lti_user_id, lti_consumer) - # If auto-linking is enabled, the lti_user should be linked to the logged-in user - if ( - lti_consumer.require_user_account and - request.user.is_authenticated and - lti_user.edx_user != request.user - ): - lti_user.edx_user = request.user - lti_user.save() - if not (request.user.is_authenticated and request.user == lti_user.edx_user): # The user is not authenticated, or is logged in as somebody else.