From 50c266f7beb9d8fe6cd8c8929a759529275143f4 Mon Sep 17 00:00:00 2001 From: Alexis Saettler <alexis@saettler.org> Date: Fri, 3 May 2024 11:43:52 +0200 Subject: [PATCH] fix: fix webauthn keys (#7261) --- ...2024_05_03_100000_update_webauthn_keys.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 database/migrations/2024_05_03_100000_update_webauthn_keys.php diff --git a/database/migrations/2024_05_03_100000_update_webauthn_keys.php b/database/migrations/2024_05_03_100000_update_webauthn_keys.php new file mode 100644 index 00000000000..b5bd698f477 --- /dev/null +++ b/database/migrations/2024_05_03_100000_update_webauthn_keys.php @@ -0,0 +1,36 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use LaravelWebauthn\Models\WebauthnKey; + +return new class extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + WebauthnKey::select(['id', 'credentialId'])->chunk(200, function ($keys) { + foreach ($keys as $key) { + $key->update(['credentialId' => $key->credentialId]); + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + WebauthnKey::select(['id', 'credentialId'])->chunk(200, function ($keys) { + foreach ($keys as $key) { + $key->setRawAttributes(['credentialId' => base64_encode($key->credentialId)]); + $key->save(); + } + }); + } +};