Skip to content

Commit

Permalink
only save if need to
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Sep 30, 2022
1 parent ebc9045 commit 9a68cf2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Actions/DisableTwoFactorAuthentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ class DisableTwoFactorAuthentication
*/
public function __invoke($user)
{
$user->forceFill([
'two_factor_secret' => null,
'two_factor_recovery_codes' => null,
] + (Fortify::confirmsTwoFactorAuthentication() ? [
'two_factor_confirmed_at' => null,
] : []))->save();
if (! is_null($user->two_factor_secret) ||
! is_null($user->two_factor_recovery_codes) ||
! is_null($user->two_factor_confirmed_at)) {
$user->forceFill([
'two_factor_secret' => null,
'two_factor_recovery_codes' => null,
] + (Fortify::confirmsTwoFactorAuthentication() ? [
'two_factor_confirmed_at' => null,
] : []))->save();
}

TwoFactorAuthenticationDisabled::dispatch($user);
}
Expand Down

0 comments on commit 9a68cf2

Please sign in to comment.