Skip to content

Commit 7774446

Browse files
committed
Code Refactored.
1 parent 0c6a77f commit 7774446

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Http/Controllers/TwoFactorAuthenticationController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class TwoFactorAuthenticationController extends Controller implements TwoFactorA
2323

2424
/**
2525
* Assigns $usersModel Property a Model instance.
26+
* Set authenticated users data to $user Property.
2627
*/
2728
public function __construct()
2829
{
@@ -42,6 +43,7 @@ public function __construct()
4243
* @param \Illuminate\Http\Response
4344
*
4445
* @throws \Thecodework\TwoFactorAuthentications\Exceptions\TwoFactorAuthenticationExceptions
46+
* @return mixed
4547
*/
4648
public function setupTwoFactorAuthentication(Request $request)
4749
{
@@ -57,7 +59,6 @@ public function setupTwoFactorAuthentication(Request $request)
5759

5860
$barcode = $totp->getQrCodeUri();
5961

60-
// Return Barcode image if ajax Request
6162
if ($request->ajax()) {
6263
return $barcode;
6364
}
@@ -69,12 +70,11 @@ public function setupTwoFactorAuthentication(Request $request)
6970
* Disable 2FA.
7071
*
7172
* @param \Illuminate\Http\Request
72-
*
7373
* @return mixed
7474
*/
7575
public function enableTwoFactorAuthentication(Request $request)
7676
{
77-
$user = $this->TwoFAModel->find($request->user()->id);
77+
$user = $this->getUser();
7878
$user->is_two_factor_enabled = 1;
7979
$user->update();
8080

@@ -99,7 +99,7 @@ public function enableTwoFactorAuthentication(Request $request)
9999
*/
100100
public function disableTwoFactorAuthentication(Request $request)
101101
{
102-
$user = $this->TwoFAModel->find($request->user()->id);
102+
$user = $this->getUser();
103103
$user->is_two_factor_enabled = 0;
104104
$user->two_factor_secret_key = null;
105105
$user->update();

0 commit comments

Comments
 (0)