BookStack/app/Http/Middleware/Authenticate.php

32 lines
657 B
PHP
Raw Normal View History

2015-07-12 21:01:42 +02:00
<?php
namespace BookStack\Http\Middleware;
2015-07-12 21:01:42 +02:00
use Closure;
use Illuminate\Http\Request;
2015-07-12 21:01:42 +02:00
class Authenticate
{
use ChecksForEmailConfirmation;
2015-07-12 21:01:42 +02:00
/**
* Handle an incoming request.
*/
public function handle(Request $request, Closure $next)
2015-07-12 21:01:42 +02:00
{
if ($this->awaitingEmailConfirmation()) {
return $this->emailConfirmationErrorResponse($request);
}
if (!hasAppAccess()) {
2015-07-12 21:01:42 +02:00
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest(url('/login'));
2015-07-12 21:01:42 +02:00
}
}
return $next($request);
}
}