Merge branch '1.8.x' into copilot/fix-3b5374b7-acb3-4c22-9573-00c1feec5bc1

This commit is contained in:
Khushboo Verma 2025-10-07 19:56:12 +05:30 committed by GitHub
commit 0c64eaf441
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 39 additions and 0 deletions

View file

@ -211,6 +211,11 @@ return [
'description' => 'User with the requested ID could not be found.',
'code' => 404,
],
Exception::USER_EMAIL_NOT_FOUND => [
'name' => Exception::USER_EMAIL_NOT_FOUND,
'description' => 'User email could not be found.',
'code' => 400,
],
Exception::USER_EMAIL_ALREADY_EXISTS => [
'name' => Exception::USER_EMAIL_ALREADY_EXISTS,
'description' => 'A user with the same email already exists in the current project.',
@ -312,11 +317,21 @@ return [
'description' => 'OAuth2 provider returned some error.',
'code' => 424,
],
Exception::USER_EMAIL_NOT_VERIFIED => [
'name' => Exception::USER_EMAIL_NOT_VERIFIED,
'description' => 'User email is not verified',
'code' => 400,
],
Exception::USER_EMAIL_ALREADY_VERIFIED => [
'name' => Exception::USER_EMAIL_ALREADY_VERIFIED,
'description' => 'User email is already verified',
'code' => 409,
],
Exception::USER_PHONE_NOT_VERIFIED => [
'name' => Exception::USER_PHONE_NOT_VERIFIED,
'description' => 'User phone is not verified',
'code' => 400,
],
Exception::USER_PHONE_ALREADY_VERIFIED => [
'name' => Exception::USER_PHONE_ALREADY_VERIFIED,
'description' => 'User phone is already verified',

View file

@ -3595,6 +3595,10 @@ App::post('/v1/account/verifications/email')
throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP Disabled');
}
if (empty($user->getAttribute('email'))) {
throw new Exception(Exception::USER_EMAIL_NOT_FOUND);
}
$url = htmlentities($url);
if ($user->getAttribute('emailVerification')) {
throw new Exception(Exception::USER_EMAIL_ALREADY_VERIFIED);

View file

@ -1921,6 +1921,26 @@ class AccountCustomClientTest extends Scope
return $session;
}
/**
* @depends testCreateAnonymousAccount
*/
public function testCreateAnonymousAccountVerification($session): array
{
$response = $this->client->call(Client::METHOD_POST, '/account/verification', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
]), [
'url' => 'http://localhost/verification',
]);
$this->assertEquals(400, $response['body']['code']);
$this->assertEquals('user_email_not_found', $response['body']['type']);
return [];
}
/**
* @depends testCreateAnonymousAccount
*/