Reset unconfirmed_email if it exists on /users/identity_verification/verify_email_code

What does this MR do and why?

Related to #505444 (closed)

Reset unconfirmed_email if it exists on /users/identity_verification/verify_email_code

Users who attempted to register prior to the email_confirmation_setting set to hard in Gitlab.com would have their primary email changed to the email set in the unconfirmed_email attribute, if present. This is an issue because the email confirmation code is sent to the user's primary email address and would result in a user confirming the wrong email. This MR adds a check to remove the unconfirmed_email address of a user before confirmation in the registrations identity verification controller.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Ensure GDK is running in SaaS mode.
    export GITLAB_SIMULATE_SAAS=1
  2. Update email confirmation settings to work with identity verification.
    ::Gitlab::CurrentSettings.update!(email_confirmation_setting: 'hard')
    ::Gitlab::CurrentSettings.update!(require_admin_approval_after_user_signup: false)
  3. Register a new user but do not verify the user's email address.
  4. Set unconfirmed_email for the user account from the Rails console:
    User.last.update(unconfirmed_email: 'user-unconfirmed@example.com')
  5. On /users/identity_verification page click Send a new code. The confirmation email should be sent to the email used to register. The email should retrieved by browsing to /rails/letter_opener in GDK.
  6. Verify the user account by using that code.
  7. Go to the user profile and verify the the user's email is the same as the one used to register and was not changed to the unconfirmed email (user-unconfirmed@example.com).
Edited by Bogdan Denkovych

Merge request reports

Loading