Skip to content

Commit

Permalink
Added Main TwoFactor
Browse files Browse the repository at this point in the history
  • Loading branch information
stanfortonski committed Jan 30, 2021
1 parent 02a6275 commit d1743e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Controllers/TwoFactorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Stanfortonski\Laraveltwofactor\Controllers;

use Stanfortonski\Laraveltwofactor\Notifications\TwoFactorCode;
use Illuminate\Http\Request;
use Stanfortonski\Laraveltwofactor\TwoFactor;

class TwoFactorController extends Controller
{
Expand Down Expand Up @@ -32,8 +32,7 @@ public function resend()
{
$user = auth()->user();
if (!empty($user->two_factor_code)){
$user->generateTwoFactorCode();
$user->notify(new TwoFactorCode());
TwoFactor::sendCode($user);
return redirect()->route('twofactor.verify.index')->withSuccess(__('twofactor::twofactor.send_again'));
}
return redirect()->route(config('twofactor.routes.return'));
Expand Down
16 changes: 16 additions & 0 deletions src/TwoFactor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Stanfortonski\Laraveltwofactor;

use Stanfortonski\Laraveltwofactor\Notifications\TwoFactorCode;

class TwoFactor
{
static public function sendCode($user)
{
if ($user->enable_two_factor){
$user->generateTwoFactorCode();
$user->notify(new TwoFactorCode());
}
}
}

0 comments on commit d1743e9

Please sign in to comment.