public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
$method = 'guest';
if ($request->method() === 'POST') {
app('session')->put('url.intended', back_url());
$method = 'to';
}
return redirect()->{$method}('auth/login')->withInfo(trans('gitamin.login.auth_prompt'));
}
}
return $next($request);
}