Skip to content

Do not allow accessing PhoneSetupController unless you are in account setup#8265

Merged
mitchellhenke merged 1 commit intomainfrom
mitchellhenke/do-not-allow-phone-setup-unless-in-account-setup
Apr 25, 2023
Merged

Do not allow accessing PhoneSetupController unless you are in account setup#8265
mitchellhenke merged 1 commit intomainfrom
mitchellhenke/do-not-allow-phone-setup-unless-in-account-setup

Conversation

@mitchellhenke
Copy link
Contributor

🛠 Summary of changes

The Users::PhoneSetupController is intended for use by users that are in account registration. Users that are not in account setup use the Users::PhonesController and Users::EditPhoneController, both of which require recent authentication. To prevent users from managing 2FA without being recently authenticated, this PR adds a check so that only users going through account registration can access this controller.

changelog: Bug Fixes, Account Management, Require being in account setup when accessing the PhoneSetupController
Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +96 to +98
return if user_fully_authenticated? && in_multi_mfa_selection_flow?
return unless MfaPolicy.new(current_user).two_factor_enabled?
redirect_to account_path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Between this and confirm_user_authenticated_for_2fa_setup, trying to think of a scenario where it's not sufficient to just check for in_multi_mfa_selection_flow? ?

Suggested change
return if user_fully_authenticated? && in_multi_mfa_selection_flow?
return unless MfaPolicy.new(current_user).two_factor_enabled?
redirect_to account_path
redirect_to account_path unless in_multi_mfa_selection_flow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could drop the user_fully_authenticated? part, but the other one I think needs to remain since most tests do not go through MFA selection :/

@mitchellhenke mitchellhenke merged commit 1db6f53 into main Apr 25, 2023
@mitchellhenke mitchellhenke deleted the mitchellhenke/do-not-allow-phone-setup-unless-in-account-setup branch April 25, 2023 12:43
@jmhooper jmhooper mentioned this pull request Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants