Created
November 12, 2016 13:14
-
-
Save jleonardolemos/f4548dc0acfbc30db1d826f82531658f to your computer and use it in GitHub Desktop.
This file contains 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\Middleware; | |
use Closure; | |
use Illuminate\Contracts\Auth\Guard; | |
use Auth; | |
class AdminAuthenticate extends Authenticate | |
{ | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next) | |
{ | |
/** | |
* TODO: Personalizar a mensagem de usuário inativo | |
*/ | |
if(!Auth::user()) { | |
return redirect()->route('admin.login.view'); | |
} | |
if (Auth::user()->status === 'inactive') { | |
return redirect()->route('admin.logout'); | |
} | |
if (Auth::user()->type != 'admix') { | |
Auth::logout(); | |
return redirect()->route('admin.login.view'); | |
} | |
/*if ($this->auth->guest()) { | |
if ($request->ajax()) { | |
return response('Unauthorized.', 401); | |
} else { | |
return redirect()->route('admin.login.view'); | |
} | |
}*/ | |
return $next($request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment