Last active
September 28, 2015 09:32
-
-
Save rawaludin/7cf4cf245ddfbc30a1af to your computer and use it in GitHub Desktop.
Lokasi: /app/Http/Middleware/UserSuspension.php
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; | |
class UserSuspension | |
{ | |
/** | |
* The Guard implementation. | |
* | |
* @var Guard | |
*/ | |
protected $auth; | |
/** | |
* Create a new filter instance. | |
* | |
* @param Guard $auth | |
* @return void | |
*/ | |
public function __construct(Guard $auth) | |
{ | |
$this->auth = $auth; | |
} | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next) | |
{ | |
$response = $next($request); | |
if ($this->auth->user()->banned == 0) { | |
return $response; | |
} | |
$this->auth->logout(); | |
return redirect()->route('login'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment