From ef3ad38a1648f75bae7f8a6e12c19f0318ff72ba Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Fri, 11 Nov 2022 18:05:43 +0100 Subject: [PATCH] Fixes query error when disabling all credentials --- src/Models/WebAuthnCredential.php | 2 +- src/WebAuthnAuthentication.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Models/WebAuthnCredential.php b/src/Models/WebAuthnCredential.php index 701a92d..6b50ff9 100644 --- a/src/Models/WebAuthnCredential.php +++ b/src/Models/WebAuthnCredential.php @@ -95,7 +95,7 @@ class WebAuthnCredential extends Model * * @var array */ - protected $visible = ['id', 'origin', 'alias', 'aaguid', 'attestation_format', 'disabled_at', 'is_enabled']; + protected $visible = ['id', 'origin', 'alias', 'aaguid', 'attestation_format', 'disabled_at']; /** * @phpstan-ignore-next-line diff --git a/src/WebAuthnAuthentication.php b/src/WebAuthnAuthentication.php index d2322bb..1623f92 100644 --- a/src/WebAuthnAuthentication.php +++ b/src/WebAuthnAuthentication.php @@ -4,6 +4,7 @@ namespace Laragear\WebAuthn; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Relations\MorphMany; +use Illuminate\Support\Facades\Date; use JetBrains\PhpStorm\ArrayShape; use Laragear\WebAuthn\Models\WebAuthnCredential; use function in_array; @@ -70,7 +71,7 @@ trait WebAuthnAuthentication } }); } else { - $this->webAuthnCredentials()->whereKeyNot($except)->update(['is_enabled' => false]); + $this->webAuthnCredentials()->whereKeyNot($except)->update(['disabled_at' => Date::now()]); } }