From 404de48cc36578c5da8fc9d08711ef2a2ab2412a Mon Sep 17 00:00:00 2001 From: "Vincent (Wen Yu) Ge" Date: Thu, 18 Apr 2024 17:08:47 -0400 Subject: [PATCH 1/3] Update user create error message for console to be console specific --- app/config/errors.php | 5 +++++ app/controllers/api/account.php | 3 +++ src/Appwrite/Extend/Exception.php | 1 + 3 files changed, 9 insertions(+) diff --git a/app/config/errors.php b/app/config/errors.php index c999ddba5..4bb9458dd 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -136,6 +136,11 @@ return [ 'description' => 'The current project has exceeded the maximum number of users. Please check your user limit in the Appwrite console.', 'code' => 501, ], + Exception::USER_CONSOLE_COUNT_EXCEEDED => [ + 'name' => Exception::USER_CONSOLE_COUNT_EXCEEDED, + 'description' => 'Sign up to the console is restricted. You can update console sign up restrictions by setting _APP_CONSOLE_WHITELIST_ROOT to "disabled" or by updating _APP_CONSOLE_WHITELIST_IPS or _APP_CONSOLE_WHITELIST_EMAILS to whitelist your IP or email.', + 'code' => 501, + ], Exception::USER_JWT_INVALID => [ 'name' => Exception::USER_JWT_INVALID, 'description' => 'The JWT token is invalid. Please check the value of the X-Appwrite-JWT header to ensure the correct token is being used.', diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index ee7dc076d..b2f121232 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -215,6 +215,9 @@ App::post('/v1/account') $total = $dbForProject->count('users', max: APP_LIMIT_USERS); if ($total >= $limit) { + if ('console' === $project->getId()){ + throw new Exception(Exception::USER_CONSOLE_COUNT_EXCEEDED); + } throw new Exception(Exception::USER_COUNT_EXCEEDED); } } diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 7d56f5a38..1c5692cd9 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -63,6 +63,7 @@ class Exception extends \Exception /** Users */ public const USER_COUNT_EXCEEDED = 'user_count_exceeded'; + public const USER_CONSOLE_COUNT_EXCEEDED = 'user_console_count_exceeded'; public const USER_JWT_INVALID = 'user_jwt_invalid'; public const USER_ALREADY_EXISTS = 'user_already_exists'; public const USER_BLOCKED = 'user_blocked'; From c57fa3546f6d65091697a5049f21151b96772ffd Mon Sep 17 00:00:00 2001 From: "Vincent (Wen Yu) Ge" Date: Thu, 18 Apr 2024 17:22:41 -0400 Subject: [PATCH 2/3] Ran formatter --- app/controllers/api/account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index b2f121232..4d9dd364f 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -215,7 +215,7 @@ App::post('/v1/account') $total = $dbForProject->count('users', max: APP_LIMIT_USERS); if ($total >= $limit) { - if ('console' === $project->getId()){ + if ('console' === $project->getId()) { throw new Exception(Exception::USER_CONSOLE_COUNT_EXCEEDED); } throw new Exception(Exception::USER_COUNT_EXCEEDED); From be05844116003d5b17f111971b8afb645a695264 Mon Sep 17 00:00:00 2001 From: "Vincent (Wen Yu) Ge" Date: Thu, 18 Apr 2024 18:18:34 -0400 Subject: [PATCH 3/3] Update error for USER_CONSOLE_COUNT_EXCEEDED to just mention relevant variables --- app/config/errors.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/errors.php b/app/config/errors.php index 4bb9458dd..47bb6d834 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -138,7 +138,7 @@ return [ ], Exception::USER_CONSOLE_COUNT_EXCEEDED => [ 'name' => Exception::USER_CONSOLE_COUNT_EXCEEDED, - 'description' => 'Sign up to the console is restricted. You can update console sign up restrictions by setting _APP_CONSOLE_WHITELIST_ROOT to "disabled" or by updating _APP_CONSOLE_WHITELIST_IPS or _APP_CONSOLE_WHITELIST_EMAILS to whitelist your IP or email.', + 'description' => 'Sign up to the console is restricted. You can contact an administrator to update console sign up restrictions by setting _APP_CONSOLE_WHITELIST_ROOT to "disabled".', 'code' => 501, ], Exception::USER_JWT_INVALID => [