1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Fixes for 2FA

This commit is contained in:
David Bomba 2021-03-15 08:40:07 +11:00
parent 1934443bff
commit 8f37a06e24
2 changed files with 9 additions and 1 deletions

View File

@ -47,11 +47,13 @@ class TwoFactorController extends BaseController
public function enableTwoFactor()
{
$google2fa = new Google2FA();
$user = auth()->user();
$secret = request()->input('secret');
$oneTimePassword = request()->input('one_time_password');
if (! $secret || ! Google2FA::verifyKey($secret, $oneTimePassword)) {
if (! $secret || ! $google2fa->verifyKey($secret, $oneTimePassword)) {
return response()->json('message' > ctrans('texts.invalid_one_time_password'));
} elseif (! $user->google_2fa_secret && $user->phone && $user->confirmed) {
$user->google_2fa_secret = encrypt($secret);

View File

@ -11,6 +11,7 @@
namespace App\Models;
use App\Services\BillingSubscription\BillingSubscriptionService;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@ -53,6 +54,11 @@ class BillingSubscription extends BaseModel
'deleted_at' => 'timestamp',
];
public function service()
{
return new BillingSubscriptionService($this);
}
public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Company::class);