feat: complete user authentication, admin guard, customer account dashboard and branded HTML emails
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class EnsureUserIsAdmin
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (! auth()->check()) {
|
||||
return redirect()->guest(route('login'))
|
||||
->with('error', 'Log eerst in met je beheerder-account om toegang te krijgen tot het admin gedeelte.');
|
||||
}
|
||||
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
return redirect()->route('home')
|
||||
->with('error', 'Je hebt geen beheerderstoegang tot deze pagina.');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user