Protect admin routes with new eloquent sessions
When using Laravel’s own auth middleware an exception would then get thrown which was being sent to Slack, hmmm. So I modified the original MyAuthMiddleware to use the Auth facade instead of a custom session key. A logout page has also been added.
This commit is contained in:
parent
db3708bbb6
commit
2e79492b01
4 changed files with 58 additions and 17 deletions
|
@ -6,6 +6,7 @@ namespace App\Http\Middleware;
|
|||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class MyAuthMiddleware
|
||||
{
|
||||
|
@ -18,7 +19,7 @@ class MyAuthMiddleware
|
|||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if ($request->session()->has('loggedin') !== true) {
|
||||
if (Auth::check($request->user()) == false) {
|
||||
//they’re not logged in, so send them to login form
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue