Skip to content

Commit 9a68cf2

Browse files
committed
only save if need to
1 parent ebc9045 commit 9a68cf2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/Actions/DisableTwoFactorAuthentication.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ class DisableTwoFactorAuthentication
1515
*/
1616
public function __invoke($user)
1717
{
18-
$user->forceFill([
19-
'two_factor_secret' => null,
20-
'two_factor_recovery_codes' => null,
21-
] + (Fortify::confirmsTwoFactorAuthentication() ? [
22-
'two_factor_confirmed_at' => null,
23-
] : []))->save();
18+
if (! is_null($user->two_factor_secret) ||
19+
! is_null($user->two_factor_recovery_codes) ||
20+
! is_null($user->two_factor_confirmed_at)) {
21+
$user->forceFill([
22+
'two_factor_secret' => null,
23+
'two_factor_recovery_codes' => null,
24+
] + (Fortify::confirmsTwoFactorAuthentication() ? [
25+
'two_factor_confirmed_at' => null,
26+
] : []))->save();
27+
}
2428

2529
TwoFactorAuthenticationDisabled::dispatch($user);
2630
}

0 commit comments

Comments
 (0)