Middleware does not fire when user is not logged in.

This commit is contained in:
James Cole 2017-12-21 19:55:28 +01:00
parent 707af8bb4e
commit 4b869f0d9e
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 5 additions and 11 deletions

View File

@ -45,12 +45,9 @@ class IsDemoUser
public function handle(Request $request, Closure $next, $guard = null) public function handle(Request $request, Closure $next, $guard = null)
{ {
if (Auth::guard($guard)->guest()) { if (Auth::guard($guard)->guest()) {
if ($request->ajax()) { // don't care when not logged in, usual stuff applies:
return response('Unauthorized.', 401); return $next($request);
} }
return redirect()->guest('login');
}
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
if ($user->hasRole('demo')) { if ($user->hasRole('demo')) {

View File

@ -45,11 +45,8 @@ class IsSandStormUser
public function handle(Request $request, Closure $next, $guard = null) public function handle(Request $request, Closure $next, $guard = null)
{ {
if (Auth::guard($guard)->guest()) { if (Auth::guard($guard)->guest()) {
if ($request->ajax()) { // don't care when not logged in, usual stuff applies:
return response('Unauthorized.', 401); return $next($request);
}
return redirect()->guest('login');
} }
if (1 === intval(getenv('SANDSTORM'))) { if (1 === intval(getenv('SANDSTORM'))) {