mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-03-14 20:39:44 +01:00
Fixed unauthorized exceptions
This commit is contained in:
parent
fad3ed9a51
commit
a7effcce7a
@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class Admin
|
||||
{
|
||||
@ -45,7 +45,7 @@ class Admin
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (!$this->auth->check() || ($this->auth->check() && !$this->auth->user()->isAdmin)) {
|
||||
throw new UnauthorizedHttpException();
|
||||
throw new HttpException(401);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
@ -15,7 +15,7 @@ use CachetHQ\Cachet\Models\User;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class ApiAuthenticate
|
||||
{
|
||||
@ -51,14 +51,14 @@ class ApiAuthenticate
|
||||
try {
|
||||
$this->auth->onceUsingId(User::findByApiToken($apiToken)->id);
|
||||
} catch (ModelNotFoundException $e) {
|
||||
throw new UnauthorizedHttpException();
|
||||
throw new HttpException(401);
|
||||
}
|
||||
} elseif ($request->getUser()) {
|
||||
if ($this->auth->onceBasic() !== null) {
|
||||
throw new UnauthorizedHttpException();
|
||||
throw new HttpException(401);
|
||||
}
|
||||
} else {
|
||||
throw new UnauthorizedHttpException();
|
||||
throw new HttpException(401);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class Authenticate
|
||||
{
|
||||
@ -45,7 +45,7 @@ class Authenticate
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->guest()) {
|
||||
throw new UnauthorizedHttpException();
|
||||
throw new HttpException(401);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
Loading…
x
Reference in New Issue
Block a user