Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Check for confirm in fortify #1433

Closed
wants to merge 4 commits into from

Conversation

michail-polatoglou
Copy link

There is a bug in the current logic for the two_factor_enabled in the SharedInertiaData middleware. It returns true even if the confirmed option in fortify.php config is set to true leading in an error if you refresh the page in the confirmation page.

This is not a problem in the default configuration of the 2FA in the jetstream profile page but if you want to move this form to a different page it causes a problem with the logic since the front end thinks the two_factor_enabled is true even if it's not confirmed and only shows you the recovery codes.

The function could be shortened to:

if (
    Features::enabled(Features::twoFactorAuthentication()) &&
    !is_null($user->two_factor_secret) &&
    (
        !Features::enabled(Features::twoFactorAuthentication(['confirm'])) ||
        !is_null($user->two_factor_confirmed_at)
    )
) {
    return true;
} else {
    return false;
}

but i expanded it for readability

@driesvints driesvints changed the title check for confirm in fortify [4.x] Check for confirm in fortify Jan 18, 2024
@taylorotwell
Copy link
Member

No plans to change this atm.

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.

None yet

2 participants