Inconsistencies on Show page 2FA

Summary

While working on Issue #346494 (closed) We figured there are Issues on the show page apart from Error not getting generated when user enters Incorrect password. The inconsistencies observed are

  1. Below Flash alert on the page when set, no other message can be displayed using flash[:alert] Screenshot_2022-10-13_at_5.43.26_PM

  2. Apart from flash we are using @error variable to display errors to the user in case of Invalid pin and Invalid password after MR - !96056 (merged) is merged. When Invalid pin error is set in controller we do not check for global settings and the alert message is not displayed to the user. As can be seen in video here

video1913700651

Steps to reproduce

  1. Be part of a group that has Require all users in this group to set up two-factor authentication enabled
  2. Log into a GitLab.com account without 2FA enabled.
  3. Go into User settings -> Preferences -> Account -> Enable Two-factor Authentication.

Check video for further steps.

Issue is the way we are using flash to set a message as soon as the page loads as described in comment here !96056 (comment 1126768577) .

Proposal

Use a separate div to display global setting message and use flash for other error messages which can be set during redirects.

Edited by Smriti Garg