Created
August 8, 2017 11:03
-
-
Save ianfagg/0ca3a581043c5379716a84ae1aa61306 to your computer and use it in GitHub Desktop.
Spark user verification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers\Auth; | |
use Laravel\Spark\Spark; | |
use Illuminate\Http\Request; | |
use Illuminate\Support\Facades\Auth; | |
use Laravel\Spark\Http\Controllers\Controller; | |
use Illuminate\Foundation\Auth\AuthenticatesUsers; | |
use Laravel\Spark\Contracts\Interactions\Settings\Security\VerifyTwoFactorAuthToken as Verify; | |
class LoginController extends \Laravel\Spark\Http\Controllers\Auth\LoginController | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
public function login(Request $request) | |
{ | |
if ($request->has('remember')) { | |
$request->session()->put('spark:auth-remember', $request->remember); | |
} | |
$user = Spark::user()->where(['email' => $request->email, 'verified' => 1])->first(); | |
if (Spark::usesTwoFactorAuth() && $user && $user->uses_two_factor_auth) { | |
$request->merge(['remember' => '']); | |
} | |
return $this->traitLogin($request); | |
} | |
public function authenticated(Request $request, $user) | |
{ | |
/** | |
* @var $user User | |
* Set some logic here of your own for new redirect location | |
*/ | |
if ($user->verified != 1) { | |
$this->guard()->logout(); | |
session()->flush(); | |
return redirect('/login')->with('status', 'Your account is not verified, please follow the instructions sent to your email address! If you cannot find it please check your \'Junk\' folder.'); | |
} | |
return parent::authenticated($request, $user); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment