From f77472170105d3403dfad23ad7247502c377dd51 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Mon, 22 May 2023 12:28:47 -0700 Subject: [PATCH 1/2] Update the error message for blocked users Remove the "You can unblock the user from the Appwrite console." part as it is not relevant for the person receiving the error. --- 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 2b21ff48e2..cba8dc8acc 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -112,7 +112,7 @@ return [ ], Exception::USER_BLOCKED => [ 'name' => Exception::USER_BLOCKED, - 'description' => 'The current user has been blocked. You can unblock the user from the Appwrite console.', + 'description' => 'The current user has been blocked.', 'code' => 401, ], Exception::USER_INVALID_TOKEN => [ From 9d13d72c71e03eda37a136f48fb46ee0a3593ec8 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Tue, 23 May 2023 10:40:31 -0700 Subject: [PATCH 2/2] Update the Update Account Status API to clear the cookie After a user updates their status, their session no longer works however, the cookie may still exist in their browser, preventing other API calls from completing successfully. --- app/controllers/api/account.php | 6 ++++++ tests/e2e/Services/Account/AccountCustomClientTest.php | 2 ++ 2 files changed, 8 insertions(+) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 7c46e634c1..e211c123ee 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1789,6 +1789,12 @@ App::patch('/v1/account/status') $response->addHeader('X-Fallback-Cookies', \json_encode([])); } + $protocol = $request->getProtocol(); + $response + ->addCookie(Auth::$cookieName . '_legacy', '', \time() - 3600, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, null) + ->addCookie(Auth::$cookieName, '', \time() - 3600, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, Config::getParam('cookieSamesite')) + ; + $response->dynamic($user, Response::MODEL_ACCOUNT); }); diff --git a/tests/e2e/Services/Account/AccountCustomClientTest.php b/tests/e2e/Services/Account/AccountCustomClientTest.php index ea24d06bdb..585c07ba59 100644 --- a/tests/e2e/Services/Account/AccountCustomClientTest.php +++ b/tests/e2e/Services/Account/AccountCustomClientTest.php @@ -221,6 +221,8 @@ class AccountCustomClientTest extends Scope ]); $this->assertEquals($response['headers']['status-code'], 200); + $this->assertStringContainsString('a_session_' . $this->getProject()['$id'] . '=deleted', $response['headers']['set-cookie']); + $this->assertEquals('[]', $response['headers']['x-fallback-cookies']); $response = $this->client->call(Client::METHOD_GET, '/account', array_merge([ 'origin' => 'http://localhost',