php - Laravel 5.1 - When registering user App redirects to /dashboard but doesn't check if account is confirmed -
when users register in app automatically redirects them /dashboard technically fine, isn't checking see if confirmed column in database has value of 1 or 0, it's logging in based on username , password.
i happily include code right don't know code guys need see.
i need check confirmed column , if it's 0, not log them in , throw , error.
thanks info,
andy
i achieve utilizing middleware:
my routes.php:
route::get('home', ['middleware' => 'auth', function () { return "this example"; }]); my kernel.php:
protected $routemiddleware = [ 'auth' => \app\http\middleware\authenticate::class, ]; my authenticate.php middleware:
<?php namespace app\http\middleware; use closure; use illuminate\contracts\auth\guard; class authenticate { /** * guard implementation. * * @var guard */ protected $auth; /** * create new filter instance. * * @param guard $auth * @return void */ public function __construct(guard $auth) { $this->auth = $auth; } /** * handle incoming request. * * @param \illuminate\http\request $request * @param \closure $next * @return mixed */ public function handle($request, closure $next) { if ($this->auth->guest()) { if ($request->ajax()) { return response('unauthorized.', 401); } else { return redirect()->guest('auth/login'); } } $user = $this->auth->user(); if (!$user->confirmed) { $this->auth->logout(); return redirect()->guest('auth/login')->with('error', 'please confirm e-mail address continue.'); } if (!$user->type) { $this->auth->logout(); return redirect()->guest('auth/login')->with('error', 'a user configuration error has occurred. please contact administrator assistance.'); } return $next($request); } } i tried cut down as possible you.
Comments
Post a Comment