Skip to content

Commit

Permalink
fix: remove re-linking from authenticate_user function
Browse files Browse the repository at this point in the history
  • Loading branch information
tecoholic committed Nov 13, 2023
1 parent 7404a96 commit 2fb1a06
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 18 deletions.
9 changes: 0 additions & 9 deletions lms/djangoapps/lti_provider/tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 0 additions & 9 deletions lms/djangoapps/lti_provider/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2fb1a06

Please sign in to comment.