Skip to content

Commit 08f4451

Browse files
committed
Clean ups.
1 parent 1ba8eb4 commit 08f4451

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/Http/Controllers/TwoFactorAuthenticationController.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Thecodework\TwoFactorAuthentication\Http\Controllers;
44

5-
use ParagonIE\ConstantTime\Base32;
65
use Illuminate\Http\Request;
76
use Illuminate\Support\Facades\Schema;
87
use OTPHP\TOTP;
8+
use ParagonIE\ConstantTime\Base32;
99
use Thecodework\TwoFactorAuthentication\AuthenticatesUsersWith2FA;
1010
use Thecodework\TwoFactorAuthentication\Contracts\TwoFactorAuthenticationInterface;
1111
use Thecodework\TwoFactorAuthentication\Exceptions\TwoFactorAuthenticationExceptions;
@@ -47,7 +47,6 @@ public function __construct()
4747
*/
4848
public function setupTwoFactorAuthentication(Request $request)
4949
{
50-
// $this->updateUserWith2FAGeneratedKey();
5150
$user = $this->getUser();
5251
$totp = TOTP::create(
5352
$this->base32EncodedString(),
@@ -58,7 +57,6 @@ public function setupTwoFactorAuthentication(Request $request)
5857
$totp->setLabel(config('2fa-config.account_name'));
5958
$this->updateUserWithProvisionedUri($totp->getProvisioningUri());
6059
$barcode = $totp->getQrCodeUri();
61-
// info($totp->getProvisioningUri());
6260
if ($request->ajax()) {
6361
return $barcode;
6462
}
@@ -75,7 +73,7 @@ public function setupTwoFactorAuthentication(Request $request)
7573
*/
7674
public function enableTwoFactorAuthentication(Request $request)
7775
{
78-
$user = $this->getUser();
76+
$user = $this->getUser();
7977
$user->is_two_factor_enabled = 1;
8078
$user->update();
8179

@@ -100,7 +98,7 @@ public function enableTwoFactorAuthentication(Request $request)
10098
*/
10199
public function disableTwoFactorAuthentication(Request $request)
102100
{
103-
$user = $this->getUser();
101+
$user = $this->getUser();
104102
$user->is_two_factor_enabled = 0;
105103
$user->two_factor_secret_key = null;
106104
$user->update();
@@ -125,7 +123,7 @@ public function disableTwoFactorAuthentication(Request $request)
125123
public function verifyTwoFactorAuthentication(Request $request)
126124
{
127125
if ($request->session()->has('2fa:user:id')) {
128-
$secret = getenv('HMAC_SECRET');
126+
$secret = getenv('HMAC_SECRET');
129127
$signature = hash_hmac('sha256', decrypt($request->session()->get('2fa:user:id')), $secret);
130128

131129
if (md5($signature) !== md5($request->signature)) {
@@ -141,13 +139,10 @@ public function verifyTwoFactorAuthentication(Request $request)
141139
/**
142140
* Encode Random String to 32 Base Transfer Encoding.
143141
*
144-
* @param int $length Length of the encoded string.
145-
*
146142
* @return string
147143
*/
148144
private function base32EncodedString():
149-
string
150-
{
145+
string {
151146
return trim(Base32::encodeUpper(random_bytes(128)), '=');
152147
}
153148

0 commit comments

Comments
 (0)