mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
feat: update account codes
This commit is contained in:
@@ -88,6 +88,11 @@ return [
|
||||
'description' => 'The request cannot be fulfilled with the current protocol. Please check the value of the _APP_OPTIONS_FORCE_HTTPS environment variable.',
|
||||
'code' => 500,
|
||||
],
|
||||
Exception::GENERAL_CODES_DISABLED => [
|
||||
'name' => Exception::GENERAL_CODES_DISABLED,
|
||||
'description' => 'Invitation codes are disabled on this server. Please contact the server administrator.',
|
||||
'code' => 500,
|
||||
],
|
||||
|
||||
/** User Errors */
|
||||
Exception::USER_COUNT_EXCEEDED => [
|
||||
@@ -125,8 +130,8 @@ return [
|
||||
'description' => 'Console registration is restricted to specific emails. Contact your administrator for more information.',
|
||||
'code' => 401,
|
||||
],
|
||||
Exception::USER_CODE_INVALID => [
|
||||
'name' => Exception::USER_CODE_INVALID,
|
||||
Exception::USER_INVALID_CODE => [
|
||||
'name' => Exception::USER_INVALID_CODE,
|
||||
'description' => 'The specified code is not valid. Contact your administrator for more information.',
|
||||
'code' => 401,
|
||||
],
|
||||
|
||||
+1
-1
Submodule app/console updated: 43891a526e...aea8c5f2bb
@@ -82,8 +82,12 @@ App::post('/v1/account/invite')
|
||||
|
||||
$whitelistCodes = (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_CODES', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_CODES', null)) : [];
|
||||
|
||||
if (empty($whitelistCodes)) {
|
||||
throw new Exception(Exception::GENERAL_CODES_DISABLED);
|
||||
}
|
||||
|
||||
if (!empty($whitelistCodes) && !\in_array($code, $whitelistCodes)) {
|
||||
throw new Exception(Exception::USER_CODE_INVALID);
|
||||
throw new Exception(Exception::USER_INVALID_CODE);
|
||||
}
|
||||
|
||||
$limit = $project->getAttribute('auths', [])['limit'] ?? 0;
|
||||
|
||||
@@ -50,6 +50,7 @@ class Exception extends \Exception
|
||||
public const GENERAL_CURSOR_NOT_FOUND = 'general_cursor_not_found';
|
||||
public const GENERAL_SERVER_ERROR = 'general_server_error';
|
||||
public const GENERAL_PROTOCOL_UNSUPPORTED = 'general_protocol_unsupported';
|
||||
public const GENERAL_CODES_DISABLED = 'general_codes_disabled';
|
||||
|
||||
/** Users */
|
||||
public const USER_COUNT_EXCEEDED = 'user_count_exceeded';
|
||||
@@ -60,7 +61,7 @@ class Exception extends \Exception
|
||||
public const USER_PASSWORD_RESET_REQUIRED = 'user_password_reset_required';
|
||||
public const USER_EMAIL_NOT_WHITELISTED = 'user_email_not_whitelisted';
|
||||
public const USER_IP_NOT_WHITELISTED = 'user_ip_not_whitelisted';
|
||||
public const USER_CODE_INVALID = 'user_code_invalid';
|
||||
public const USER_INVALID_CODE = 'user_invalid_code';
|
||||
public const USER_INVALID_CREDENTIALS = 'user_invalid_credentials';
|
||||
public const USER_ANONYMOUS_CONSOLE_PROHIBITED = 'user_anonymous_console_prohibited';
|
||||
public const USER_SESSION_ALREADY_EXISTS = 'user_session_already_exists';
|
||||
@@ -179,6 +180,7 @@ class Exception extends \Exception
|
||||
public const DOMAIN_VERIFICATION_FAILED = 'domain_verification_failed';
|
||||
|
||||
protected $type = '';
|
||||
protected $errors = [];
|
||||
|
||||
public function __construct(string $type = Exception::GENERAL_UNKNOWN, string $message = null, int $code = null, \Throwable $previous = null)
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@ class AccountConsoleClientTest extends Scope
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 401);
|
||||
$this->assertEquals($response['body']['type'], Exception::USER_CODE_INVALID);
|
||||
$this->assertEquals($response['body']['type'], Exception::USER_INVALID_CODE);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/account/invite', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
@@ -52,7 +52,7 @@ class AccountConsoleClientTest extends Scope
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 401);
|
||||
$this->assertEquals($response['body']['type'], Exception::USER_CODE_INVALID);
|
||||
$this->assertEquals($response['body']['type'], Exception::GENERAL_CODES_DISABLED);
|
||||
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
|
||||
Reference in New Issue
Block a user