mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Add admin middleware
This commit is contained in:
parent
d8303e7de5
commit
05df1c6a5f
2 changed files with 25 additions and 0 deletions
|
@ -51,6 +51,7 @@ class Kernel extends HttpKernel
|
|||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'admin' => \App\Http\Middleware\Admin::class,
|
||||
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
|
|
24
app/Http/Middleware/Admin.php
Normal file
24
app/Http/Middleware/Admin.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Auth, Closure;
|
||||
|
||||
class Admin
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if(Auth::check() == false || Auth::user()->is_admin == false) {
|
||||
return redirect(config('app.url'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue