mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Added 2FA secret to update key command
This commit is contained in:
parent
29d3f6cf1d
commit
6996e3abd2
@ -6,7 +6,9 @@ use Illuminate\Console\Command;
|
|||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use App\Models\AccountGateway;
|
use App\Models\AccountGateway;
|
||||||
use App\Models\BankAccount;
|
use App\Models\BankAccount;
|
||||||
|
use App\Models\User;
|
||||||
use Artisan;
|
use Artisan;
|
||||||
|
use Crypt;
|
||||||
use Illuminate\Encryption\Encrypter;
|
use Illuminate\Encryption\Encrypter;
|
||||||
use Laravel\LegacyEncrypter\McryptEncrypter;
|
use Laravel\LegacyEncrypter\McryptEncrypter;
|
||||||
|
|
||||||
@ -42,6 +44,7 @@ class UpdateKey extends Command
|
|||||||
// load the current values
|
// load the current values
|
||||||
$gatewayConfigs = [];
|
$gatewayConfigs = [];
|
||||||
$bankUsernames = [];
|
$bankUsernames = [];
|
||||||
|
$twoFactorSecrets = [];
|
||||||
|
|
||||||
foreach (AccountGateway::all() as $gateway) {
|
foreach (AccountGateway::all() as $gateway) {
|
||||||
if ($legacy) {
|
if ($legacy) {
|
||||||
@ -59,6 +62,14 @@ class UpdateKey extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (User::where('google_2fa_secret', '!=', '')->get() as $user) {
|
||||||
|
if ($legacy) {
|
||||||
|
$twoFactorSecrets[$user->id] = $legacy->decrypt($user->google_2fa_secret);
|
||||||
|
} else {
|
||||||
|
$twoFactorSecrets[$user->id] = Crypt::decrypt($user->google_2fa_secret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check if we can write to the .env file
|
// check if we can write to the .env file
|
||||||
$envPath = base_path() . '/.env';
|
$envPath = base_path() . '/.env';
|
||||||
$envWriteable = file_exists($envPath) && @fopen($envPath, 'a');
|
$envWriteable = file_exists($envPath) && @fopen($envPath, 'a');
|
||||||
@ -86,6 +97,12 @@ class UpdateKey extends Command
|
|||||||
$bank->save();
|
$bank->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (User::where('google_2fa_secret', '!=', '')->get() as $user) {
|
||||||
|
$secret = $twoFactorSecrets[$user->id];
|
||||||
|
$user->google_2fa_secret = $crypt->encrypt($secret);
|
||||||
|
$user->save();
|
||||||
|
}
|
||||||
|
|
||||||
$message = date('r') . ' Successfully updated ';
|
$message = date('r') . ' Successfully updated ';
|
||||||
if ($envWriteable) {
|
if ($envWriteable) {
|
||||||
if ($legacy) {
|
if ($legacy) {
|
||||||
|
@ -510,7 +510,7 @@ class AccountRepository
|
|||||||
|
|
||||||
public function registerNinjaUser($user)
|
public function registerNinjaUser($user)
|
||||||
{
|
{
|
||||||
if ($user->email == TEST_USERNAME) {
|
if (! $user || $user->email == TEST_USERNAME) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user