Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use App\Http\Requests\SettingsRequest;
use Illuminate\Support\Facades\Storage;
use App\Http\Requests\InvitationRequest;
use PragmaRX\Google2FALaravel\Support\Authenticator;
use PragmaRX\Google2FALaravel\Google2FA;

class SettingsController extends Controller
{
Expand Down Expand Up @@ -437,6 +437,6 @@ public function api()

public function security(Request $request)
{
return view('settings.security.index', ['is2FAActivated' => (new Authenticator($request))->isActivated()]);
return view('settings.security.index', ['is2FAActivated' => app('pragmarx.google2fa')->isActivated()]);
}
}
10 changes: 2 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
"license": "AGPL",
"keywords": ["prm", "crm", "social"],
"type": "project",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/asbiin/google2fa-laravel"
}
],
"require": {
"php": ">=7.0.0",
"ext-intl": "*",
Expand All @@ -27,10 +21,10 @@
"laravel/passport": "^4.0",
"laravel/socialite": "^3.0",
"league/flysystem-aws-s3-v3": "~1.0",
"martinlindhe/laravel-vue-i18n-generator": "^0.1.21",
"martinlindhe/laravel-vue-i18n-generator": "^0.1.23",
"paragonie/constant_time_encoding": "^2.2",
"pragmarx/google2fa": "^2.0",
"pragmarx/google2fa-laravel": "dev-create-authenticator-controller",
"pragmarx/google2fa-laravel": "dev-master",
"pragmarx/recovery": "^0.1.0",
"predis/predis": "^1.1",
"roave/security-advisories": "dev-master",
Expand Down
86 changes: 42 additions & 44 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 7 additions & 12 deletions tests/Unit/Google2FATest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Illuminate\Session\Store;
use App\Http\Requests\Request;
use Illuminate\Session\NullSessionHandler;
use PragmaRX\Google2FALaravel\Support\Authenticator;

class Google2FATest extends TestCase
{
Expand All @@ -22,9 +21,7 @@ public function testGoogle2faWrongKey()

$secret = $google2fa->generateSecretKey(32);

$authenticator = new Authenticator(request());

$result = $authenticator->verifyGoogle2FA($secret, 'aaaaaa');
$result = $google2fa->verifyGoogle2FA($secret, 'aaaaaa');

$this->assertEquals(false, $result);
}
Expand All @@ -41,9 +38,7 @@ public function testGoogle2faGoodKey()
$secret = $google2fa->generateSecretKey(32);
$one_time_password = $google2fa->getCurrentOtp($secret);

$authenticator = new Authenticator(request());

$result = $authenticator->verifyGoogle2FA($secret, $one_time_password);
$result = $google2fa->verifyGoogle2FA($secret, $one_time_password);

$this->assertEquals(true, $result);
}
Expand All @@ -69,14 +64,14 @@ public function testGoogle2faLogin()
$request->setLaravelSession(new Store('test', new NullSessionHandler));
$request->getSession()->start();

$authenticator = new Authenticator($request);
$authenticator = new \PragmaRX\Google2FALaravel\Support\Authenticator($request);

$this->assertEquals(false, $authenticator->canPassWithoutCheckingOTP());
$this->assertEquals(false, $authenticator->isAuthenticated());

$this->assertEquals(true, $authenticator->isActivated());
$this->assertEquals(true, $google2fa->isActivated());

$authenticator->login();
$google2fa->login();

$this->assertEquals(true, $authenticator->canPassWithoutCheckingOTP());
$this->assertEquals(true, $authenticator->isAuthenticated());
}
}