fix(lms): do not create a duplicative authentication option for teachers #57999
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously during LMS new user initialization for teachers via NRPS, the email address of the teacher was added using
User.update_primary_contact_info
. This function will look up the user and check for an existing auth option, for which none will be found for a new user. As a fallback, this function will create a new auth option using credential typeEMAIL
and return.Subsequently, the
initialize_lti_user_from_nrps
function will add the LTI authentication option with the same email. This results in a two authentication options with the same email which fails theAuthenticationOption
email_must_be_unique
validation causing a 422 error to be thrown back to the user.In the SSO user creation flow,
PartialRegistration
updates the primary contact info to the first authentication option, causing the subsequent call toupdate_primary_contact_info
to select the LTI auth option.This PR updates the logic to set the primary contact info to the LTI authentication option directly bypassing the second auth option that was created.
Links
Testing story
Deployment strategy
Follow-up work
Privacy
Security
Caching
PR Checklist: