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

Fix ShareInertiaData middleware for Eloquent strict mode when 2FA is disabled #1319

Merged
merged 1 commit into from
Jun 7, 2023

Conversation

onlime
Copy link
Contributor

@onlime onlime commented Jun 7, 2023

When we don't want to have 2FA Fortify feature Features::twoFactorAuthentication() enabled, we usually don't have any two_factor_* (namely two_factor_secret) columns on our User model / in our migration. In that case, we couldn't enable Eloquent Strictness, which is recommended for non-production environments. Enabled Model::preventSilentlyDiscardingAttributes() would throw the following MissingAttributeException exception:

The attribute [two_factor_secret] either does not exist or was not retrieved for model [App\Models\User].

This happens on Http/Middleware/ShareInertiaData.php#L57 when trying to access the non-existing attribute:

'two_factor_enabled' => ! is_null($user->two_factor_secret),

This is a simple fix by adding an additional check if the 2FA feature is enabled.

…entAccessingMissingAttributes) on disabled 2FA
@taylorotwell taylorotwell merged commit c65656c into laravel:3.x Jun 7, 2023
7 checks passed
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