for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Mpociot\Reauthenticate\Middleware;
use Carbon\Carbon;
use Closure;
class Reauthenticate
{
/**
* Number of minutes a successful Reauthentication is valid.
*
* @var int
*/
protected $reauthTime = 30;
* Validate a reauthenticated Session data.
* @param \Illuminate\Session\Store $session
* @return bool
private function validAuth($session)
$validationTime = Carbon::createFromTimestamp($session->get('reauthenticate.life', 0));
return $session->get('reauthenticate.authenticated', false) &&
($validationTime->diffInMinutes() <= $this->reauthTime);
}
* Handle an incoming request.
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
public function handle($request, Closure $next)
if (!$this->validAuth($request->session())) {
$request->session()->set('url.intended', $request->url());
return $this->invalidated($request);
return $next($request);
* Handle invalidated auth.
protected function invalidated($request)
$request
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
return redirect('auth/reauthenticate');
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.