From 08bf5aace4de6d3a9d2c2920b6e19b119ff52ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 7 May 2024 09:01:57 +0000 Subject: [PATCH 1/2] Mark email verified after email OTP --- app/controllers/api/account.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 90a35ede7..6190cec90 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -123,7 +123,8 @@ $createSession = function (string $userId, string $secret, Request $request, Res Authorization::skip(fn () => $dbForProject->deleteDocument('tokens', $verifiedToken->getId())); $dbForProject->purgeCachedDocument('users', $user->getId()); - if ($verifiedToken->getAttribute('type') === Auth::TOKEN_TYPE_MAGIC_URL) { + // Magic URL + Email OTP + if ($verifiedToken->getAttribute('type') === Auth::TOKEN_TYPE_MAGIC_URL || $verifiedToken->getAttribute('type') === Auth::TOKEN_TYPE_EMAIL) { $user->setAttribute('emailVerification', true); } From 4c6f01ad6835e675236e5ef98502e5ba626506cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 7 May 2024 09:05:54 +0000 Subject: [PATCH 2/2] Update tests --- tests/e2e/Services/Account/AccountBase.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/e2e/Services/Account/AccountBase.php b/tests/e2e/Services/Account/AccountBase.php index d61f44ca1..2d7262512 100644 --- a/tests/e2e/Services/Account/AccountBase.php +++ b/tests/e2e/Services/Account/AccountBase.php @@ -202,6 +202,8 @@ trait AccountBase $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals($userId, $response['body']['$id']); + $this->assertEquals($userId, $response['body']['$id']); + $this->assertTrue($response['body']['emailVerification']); $response = $this->client->call(Client::METHOD_POST, '/account/sessions/token', array_merge([ 'origin' => 'http://localhost',