Set Imports IDs from constants

This commit is contained in:
Bubka 2022-10-10 13:44:12 +02:00
parent e5c21d1189
commit 5c35f815ba
3 changed files with 6 additions and 2 deletions

View File

@ -50,6 +50,9 @@ class TwoFAccount extends Model implements Sortable
const DEFAULT_DIGITS = 6; const DEFAULT_DIGITS = 6;
const DEFAULT_ALGORITHM = self::SHA1; const DEFAULT_ALGORITHM = self::SHA1;
const DUPLICATE_ID = -1;
const FAKE_ID = -2;
private const IMAGELINK_STORAGE_PATH = 'imagesLink/'; private const IMAGELINK_STORAGE_PATH = 'imagesLink/';
/** /**

View File

@ -10,6 +10,7 @@ use Illuminate\Support\Arr;
use App\Exceptions\InvalidMigrationDataException; use App\Exceptions\InvalidMigrationDataException;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use App\Helpers\Helpers; use App\Helpers\Helpers;
use App\Facades\TwoFAccounts;
class AegisMigrator extends Migrator class AegisMigrator extends Migrator
{ {
@ -106,7 +107,7 @@ class AegisMigrator extends Migrator
// The token failed to generate a valid account so we create a fake account to be returned. // The token failed to generate a valid account so we create a fake account to be returned.
$fakeAccount = new TwoFAccount(); $fakeAccount = new TwoFAccount();
$fakeAccount->id = -2; $fakeAccount->id = TwoFAccount::FAKE_ID;
$fakeAccount->otp_type = $otp_parameters['type']; $fakeAccount->otp_type = $otp_parameters['type'];
// Only basic fields are filled to limit the risk of another exception. // Only basic fields are filled to limit the risk of another exception.
$fakeAccount->account = $otp_parameters['name']; $fakeAccount->account = $otp_parameters['name'];

View File

@ -101,7 +101,7 @@ class TwoFAccountService
&& $value->digits == $twofaccount->digits && $value->digits == $twofaccount->digits
&& $value->algorithm == $twofaccount->algorithm; && $value->algorithm == $twofaccount->algorithm;
})) { })) {
$twofaccount->id = -1; $twofaccount->id = TwoFAccount::DUPLICATE_ID;
} }
return $twofaccount; return $twofaccount;