-
-
Save ahmedash95/12ca44d159b780e2394cb4e8d45704db 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 Cartalyst\Sentinel\Laravel\Facades\Sentinel; | |
use Closure; | |
class checkChangePasswordMiddleware | |
{ | |
/** | |
* The URIs that should be excluded from CSRF verification. | |
* | |
* @var array | |
*/ | |
protected $except = [ | |
'profile' | |
]; | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next) | |
{ | |
if($this->inExceptArray($request)){ | |
return $next; | |
} | |
$user = Sentinel::getUser(); | |
// if($user) | |
// { | |
if($user->change_password == 0) | |
{ | |
return redirect()->route('user.profile'); | |
} | |
else | |
{ | |
return $next($request); | |
} | |
// } | |
// else | |
// { | |
// return $next($request); | |
// } | |
} | |
/** | |
* Determine if the request has a URI that should pass through CSRF verification. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return bool | |
*/ | |
protected function inExceptArray($request) | |
{ | |
foreach ($this->except as $except) { | |
if ($except !== '/') { | |
$except = trim($except, '/'); | |
} | |
if ($request->is($except)) { | |
return true; | |
} | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment