mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-01-23 06:38:34 +01:00
Fix migrations
This commit is contained in:
parent
db284c9343
commit
7c0613ac77
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use App\Classes\Options;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@ -31,17 +30,18 @@ public function up()
|
||||
|
||||
|
||||
$twofaccounts = DB::table('twofaccounts')->select('id', 'legacy_uri')->get();
|
||||
$settingService = resolve('App\Services\SettingServiceInterface');
|
||||
|
||||
foreach ($twofaccounts as $twofaccount) {
|
||||
try {
|
||||
$legacy_uri = Options::get('useEncryption') ? Crypt::decryptString($twofaccount->legacy_uri) : $twofaccount->legacy_uri;
|
||||
$legacy_uri = $settingService->get('useEncryption') ? Crypt::decryptString($twofaccount->legacy_uri) : $twofaccount->legacy_uri;
|
||||
$token = \OTPHP\Factory::loadFromProvisioningUri($legacy_uri);
|
||||
|
||||
$affected = DB::table('twofaccounts')
|
||||
->where('id', $twofaccount->id)
|
||||
->update([
|
||||
'otp_type' => get_class($token) === 'OTPHP\TOTP' ? 'totp' : 'hotp',
|
||||
'secret' => Options::get('useEncryption') ? Crypt::encryptString($token->getSecret()) : $token->getSecret(),
|
||||
'secret' => $settingService->get('useEncryption') ? Crypt::encryptString($token->getSecret()) : $token->getSecret(),
|
||||
'algorithm' => $token->getDigest(),
|
||||
'digits' => $token->getDigits(),
|
||||
'period' => $token->hasParameter('period') ? $token->getParameter('period') : null,
|
||||
|
@ -26,9 +26,6 @@ public function up()
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
||||
$table->text('account')->nullable()->change();
|
||||
$table->string('service')->nullable(false)->change();
|
||||
});
|
||||
//
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user