feat: update error codes in the accounts API
This commit is contained in:
parent
d3efbc1ef5
commit
696709c46c
|
@ -92,6 +92,16 @@ return [
|
||||||
'description' => 'The current user has been blocked. Please contact the project administrator for more information.',
|
'description' => 'The current user has been blocked. Please contact the project administrator for more information.',
|
||||||
'statusCode' => 401,
|
'statusCode' => 401,
|
||||||
],
|
],
|
||||||
|
Exception::USER_ANONYMOUS_CONSOLE_PROHIBITED => [
|
||||||
|
'name' => Exception::USER_ANONYMOUS_CONSOLE_PROHIBITED,
|
||||||
|
'description' => 'Anonymous users cannot be created for console project.',
|
||||||
|
'statusCode' => 401,
|
||||||
|
],
|
||||||
|
Exception::USER_SESSION_ALREADY_EXISTS => [
|
||||||
|
'name' => Exception::USER_SESSION_ALREADY_EXISTS,
|
||||||
|
'description' => 'Cannot create anonymous user when a session is active.',
|
||||||
|
'statusCode' => 401,
|
||||||
|
],
|
||||||
Exception::USER_CREATION_FAILED => [
|
Exception::USER_CREATION_FAILED => [
|
||||||
'name' => Exception::USER_CREATION_FAILED,
|
'name' => Exception::USER_CREATION_FAILED,
|
||||||
'description' => 'There was an internal server error while creating the user.',
|
'description' => 'There was an internal server error while creating the user.',
|
||||||
|
|
|
@ -912,11 +912,11 @@ App::post('/v1/account/sessions/anonymous')
|
||||||
$protocol = $request->getProtocol();
|
$protocol = $request->getProtocol();
|
||||||
|
|
||||||
if ('console' === $project->getId()) {
|
if ('console' === $project->getId()) {
|
||||||
throw new Exception('Failed to create anonymous user.', 401);
|
throw new Exception('Failed to create anonymous user.', 401, Exception::USER_ANONYMOUS_CONSOLE_PROHIBITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$user->isEmpty()) {
|
if (!$user->isEmpty()) {
|
||||||
throw new Exception('Cannot create an anonymous user when logged in.', 401, Exception::TYPE_SESSION_ALREADY_EXISTS);
|
throw new Exception('Cannot create an anonymous user when logged in.', 401, Exception::USER_SESSION_ALREADY_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
$limit = $project->getAttribute('auths', [])['limit'] ?? 0;
|
$limit = $project->getAttribute('auths', [])['limit'] ?? 0;
|
||||||
|
|
|
@ -25,19 +25,21 @@ class Exception extends \Exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Users */
|
/** Users */
|
||||||
const USER_COUNT_EXCEEDED = 'user_count_exceeded';
|
const USER_COUNT_EXCEEDED = 'user_count_exceeded';
|
||||||
const USER_ALREADY_EXISTS = 'user_already_exists';
|
const USER_ALREADY_EXISTS = 'user_already_exists';
|
||||||
const USER_BLOCKED = 'user_blocked';
|
const USER_BLOCKED = 'user_blocked';
|
||||||
const USER_CREATION_FAILED = 'user_creation_failed';
|
const USER_CREATION_FAILED = 'user_creation_failed';
|
||||||
const USER_INVALID_TOKEN = 'user_invalid_token';
|
const USER_INVALID_TOKEN = 'user_invalid_token';
|
||||||
const USER_NOT_FOUND = 'user_not_found';
|
const USER_NOT_FOUND = 'user_not_found';
|
||||||
const USER_INVALID_CREDENTIALS = 'user_invalid_credentials';
|
const USER_INVALID_CREDENTIALS = 'user_invalid_credentials';
|
||||||
const USER_EMAIL_ALREADY_EXISTS = 'user_email_already_exists';
|
const USER_EMAIL_ALREADY_EXISTS = 'user_email_already_exists';
|
||||||
const USER_PASSWORD_MISMATCH = 'user_password_mismatch';
|
const USER_PASSWORD_MISMATCH = 'user_password_mismatch';
|
||||||
const USER_AUTH_METHOD_UNSUPPORTED = 'user_auth_method_unsupported';
|
const USER_AUTH_METHOD_UNSUPPORTED = 'user_auth_method_unsupported';
|
||||||
const USER_PASSWORD_RESET_REQUIRED = 'user_password_reset_required';
|
const USER_PASSWORD_RESET_REQUIRED = 'user_password_reset_required';
|
||||||
const USER_EMAIL_NOT_WHITELISTED = 'user_email_not_whitelisted';
|
const USER_EMAIL_NOT_WHITELISTED = 'user_email_not_whitelisted';
|
||||||
const USER_IP_NOT_WHITELISTED = 'user_ip_not_whitelisted';
|
const USER_IP_NOT_WHITELISTED = 'user_ip_not_whitelisted';
|
||||||
|
const USER_SESSION_ALREADY_EXISTS = 'user_session_already_exists';
|
||||||
|
const USER_ANONYMOUS_CONSOLE_PROHIBITED = 'user_anonymous_console_prohibited';
|
||||||
|
|
||||||
/** OAuth **/
|
/** OAuth **/
|
||||||
const OAUTH_PROVIDER_DISABLED = 'oauth_provider_disabled';
|
const OAUTH_PROVIDER_DISABLED = 'oauth_provider_disabled';
|
||||||
|
|
Loading…
Reference in a new issue