Added HTTP status codes to exception interceptors
This commit is contained in:
parent
956283f4a0
commit
bba35875a3
5 changed files with 29 additions and 18 deletions
|
@ -39,6 +39,7 @@ class ApiController extends AbstractController
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
|
\Chibi\Util\Headers::setCode(400);
|
||||||
Messenger::fail($e->getMessage());
|
Messenger::fail($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ class AuthController extends AbstractController
|
||||||
}
|
}
|
||||||
catch (SimpleException $e)
|
catch (SimpleException $e)
|
||||||
{
|
{
|
||||||
|
\Chibi\Util\Headers::setCode(400);
|
||||||
Messenger::fail($e->getMessage());
|
Messenger::fail($e->getMessage());
|
||||||
$this->renderView('auth-login');
|
$this->renderView('auth-login');
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ class PostController extends AbstractController
|
||||||
}
|
}
|
||||||
catch (SimpleException $e)
|
catch (SimpleException $e)
|
||||||
{
|
{
|
||||||
|
\Chibi\Util\Headers::setCode(400);
|
||||||
Messenger::fail($e->getMessage());
|
Messenger::fail($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,7 @@ class TagController extends AbstractController
|
||||||
}
|
}
|
||||||
catch (SimpleException $e)
|
catch (SimpleException $e)
|
||||||
{
|
{
|
||||||
|
\Chibi\Util\Headers::setCode(400);
|
||||||
Messenger::fail($e->getMessage());
|
Messenger::fail($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +120,7 @@ class TagController extends AbstractController
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
|
\Chibi\Util\Headers::setCode(400);
|
||||||
Messenger::fail($e->getMessage());
|
Messenger::fail($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ class UserController extends AbstractController
|
||||||
}
|
}
|
||||||
catch (SimpleException $e)
|
catch (SimpleException $e)
|
||||||
{
|
{
|
||||||
|
\Chibi\Util\Headers::setCode(400);
|
||||||
Messenger::fail($e->getMessage());
|
Messenger::fail($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +107,7 @@ class UserController extends AbstractController
|
||||||
}
|
}
|
||||||
catch (SimpleException $e)
|
catch (SimpleException $e)
|
||||||
{
|
{
|
||||||
|
\Chibi\Util\Headers::setCode(400);
|
||||||
Messenger::fail($e->getMessage());
|
Messenger::fail($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,6 +134,7 @@ class UserController extends AbstractController
|
||||||
}
|
}
|
||||||
catch (SimpleException $e)
|
catch (SimpleException $e)
|
||||||
{
|
{
|
||||||
|
\Chibi\Util\Headers::setCode(400);
|
||||||
Messenger::fail($e->getMessage());
|
Messenger::fail($e->getMessage());
|
||||||
$this->renderView('user-view');
|
$this->renderView('user-view');
|
||||||
}
|
}
|
||||||
|
@ -233,6 +236,7 @@ class UserController extends AbstractController
|
||||||
}
|
}
|
||||||
catch (SimpleException $e)
|
catch (SimpleException $e)
|
||||||
{
|
{
|
||||||
|
\Chibi\Util\Headers::setCode(400);
|
||||||
Messenger::fail($e->getMessage());
|
Messenger::fail($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,30 +256,31 @@ class UserController extends AbstractController
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (empty($tokenText))
|
if (empty($tokenText))
|
||||||
{
|
{
|
||||||
Api::run(
|
Api::run(
|
||||||
new ActivateUserEmailJob(),
|
new ActivateUserEmailJob(),
|
||||||
$this->appendUserIdentifierArgument([], $identifier));
|
$this->appendUserIdentifierArgument([], $identifier));
|
||||||
|
|
||||||
Messenger::success('Activation e-mail resent.');
|
Messenger::success('Activation e-mail resent.');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$user = Api::run(new ActivateUserEmailJob(), [
|
$user = Api::run(new ActivateUserEmailJob(), [
|
||||||
JobArgs::ARG_TOKEN => $tokenText ]);
|
JobArgs::ARG_TOKEN => $tokenText ]);
|
||||||
|
|
||||||
$message = 'Activation completed successfully.';
|
$message = 'Activation completed successfully.';
|
||||||
if (Core::getConfig()->registration->staffActivation)
|
if (Core::getConfig()->registration->staffActivation)
|
||||||
$message .= ' However, your account still must be confirmed by staff.';
|
$message .= ' However, your account still must be confirmed by staff.';
|
||||||
Messenger::success($message);
|
Messenger::success($message);
|
||||||
|
|
||||||
if (!Core::getConfig()->registration->staffActivation)
|
if (!Core::getConfig()->registration->staffActivation)
|
||||||
Auth::setCurrentUser($user);
|
Auth::setCurrentUser($user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SimpleException $e)
|
catch (SimpleException $e)
|
||||||
{
|
{
|
||||||
|
\Chibi\Util\Headers::setCode(400);
|
||||||
Messenger::fail($e->getMessage());
|
Messenger::fail($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,6 +321,7 @@ class UserController extends AbstractController
|
||||||
}
|
}
|
||||||
catch (SimpleException $e)
|
catch (SimpleException $e)
|
||||||
{
|
{
|
||||||
|
\Chibi\Util\Headers::setCode(400);
|
||||||
Messenger::fail($e->getMessage());
|
Messenger::fail($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue