Skip to content

Commit

Permalink
Merge pull request #112 from creative-commoners/pulls/4.5/handle-unse…
Browse files Browse the repository at this point in the history
…rialize

FIX Handle updated serialize methods in silverstripe/mfa
  • Loading branch information
Maxime Rainville authored May 13, 2022
2 parents 874c2d8 + 879efef commit 1fcf89e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"require": {
"php": "^7.4 || ^8.0",
"ext-bcmath": "*",
"silverstripe/mfa": "^4.0",
"silverstripe/mfa": "^4.6",
"web-auth/webauthn-lib": "^3.3",
"guzzlehttp/psr7": "^2"
},
Expand Down
4 changes: 3 additions & 1 deletion src/CredentialRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ public function hasChanged(): bool
protected function setCredentials(array $credentials): void
{
$this->credentials = array_map(function ($data) {
$data['source'] = PublicKeyCredentialSource::createFromArray($data['source']);
if (is_array($data['source'])) {
$data['source'] = PublicKeyCredentialSource::createFromArray($data['source']);
}
return $data;
}, $credentials ?? []);
}
Expand Down
8 changes: 6 additions & 2 deletions src/RegisterHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,12 @@ protected function getCredentialCreationOptions(
): PublicKeyCredentialCreationOptions {
$state = $store->getState();

if (!$reset && !empty($state) && !empty($state['credentialOptions'])) {
return PublicKeyCredentialCreationOptions::createFromArray($state['credentialOptions']);
if (
!$reset &&
isset($state['credentialOptions']) &&
$state['credentialOptions'] instanceof PublicKeyCredentialCreationOptions
) {
return $state['credentialOptions'];
}

$credentialOptions = new PublicKeyCredentialCreationOptions(
Expand Down
8 changes: 6 additions & 2 deletions src/VerifyHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,12 @@ protected function getCredentialRequestOptions(
): PublicKeyCredentialRequestOptions {
$state = $store->getState();

if (!$reset && !empty($state) && !empty($state['credentialOptions'])) {
return PublicKeyCredentialRequestOptions::createFromArray($state['credentialOptions']);
if (
!$reset &&
isset($state['credentialOptions']) &&
$state['credentialOptions'] instanceof PublicKeyCredentialRequestOptions
) {
return $state['credentialOptions'];
}

// Use the interface methods (despite the fact the "repository" is per-member in this module)
Expand Down

0 comments on commit 1fcf89e

Please sign in to comment.