Set missing parameters to null to prevent error at import - Fixes #277

This commit is contained in:
Bubka 2024-01-17 08:33:03 +01:00
parent 1a9f011809
commit f4edbcd044
3 changed files with 8 additions and 8 deletions

View File

@ -52,8 +52,8 @@ public function migrate(mixed $migrationPayload) : Collection
$parameters['service'] = $otp_parameters['issuer'];
$parameters['account'] = $otp_parameters['name'] ?? $parameters['service'];
$parameters['secret'] = $this->padToValidBase32Secret($otp_parameters['info']['secret']);
$parameters['algorithm'] = $otp_parameters['info']['algo'];
$parameters['digits'] = $otp_parameters['info']['digits'];
$parameters['algorithm'] = $otp_parameters['info']['algo'] ?? null;
$parameters['digits'] = $otp_parameters['info']['digits'] ?? null;
$parameters['counter'] = $otp_parameters['info']['counter'] ?? null;
$parameters['period'] = $otp_parameters['info']['period'] ?? null;

View File

@ -86,12 +86,12 @@ public function migrate(mixed $migrationPayload) : Collection
$parameters['service'] = $otp_parameters['name'];
$parameters['account'] = $otp_parameters['otp']['account'] ?? $parameters['service'];
$parameters['secret'] = $this->padToValidBase32Secret($otp_parameters['secret']);
$parameters['algorithm'] = $otp_parameters['otp']['algorithm'];
$parameters['digits'] = $otp_parameters['otp']['digits'];
$parameters['counter'] = strtolower($parameters['otp_type']) === 'hotp' && $otp_parameters['otp']['counter'] > 0
$parameters['algorithm'] = $otp_parameters['otp']['algorithm'] ?? null;
$parameters['digits'] = $otp_parameters['otp']['digits'] ?? null;
$parameters['counter'] = strtolower($parameters['otp_type']) === 'hotp' && Arr::has($otp_parameters['otp'], 'counter')
? $otp_parameters['otp']['counter']
: null;
$parameters['period'] = strtolower($parameters['otp_type']) === 'totp' && $otp_parameters['otp']['period'] > 0
$parameters['period'] = strtolower($parameters['otp_type']) === 'totp' && Arr::has($otp_parameters['otp'], 'period')
? $otp_parameters['otp']['period']
: null;

View File

@ -55,8 +55,8 @@ public function migrate(mixed $migrationPayload) : Collection
$parameters['service'] = $otp_parameters['service'];
$parameters['account'] = $otp_parameters['account'];
$parameters['secret'] = $this->padToValidBase32Secret($otp_parameters['secret']);
$parameters['algorithm'] = $otp_parameters['algorithm'];
$parameters['digits'] = $otp_parameters['digits'];
$parameters['algorithm'] = $otp_parameters['algorithm'] ?? null;
$parameters['digits'] = $otp_parameters['digits'] ?? null;
$parameters['legacy_uri'] = $otp_parameters['legacy_uri'];
$parameters['counter'] = strtolower($parameters['otp_type']) === 'hotp' && $otp_parameters['counter'] > 0
? $otp_parameters['counter']