diff --git a/CHANGELOG.md b/CHANGELOG.md index 74e0650..534d18f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ v1.5 ---- +- Fix FLEXIAPI-174 Check if the phone is valid before trying to recover it (deprecated endpoint) - Fix FLEXIAPI-173 Wrong route in validateEmail (deprecated) - Fix FLEXIAPI-171 Fix README documentation for CreateAdminAccount - Fix FLEXIAPI-170 Fix undefined variable apiKey in CreateAdminAccount diff --git a/flexiapi/app/Http/Controllers/Api/Account/AccountController.php b/flexiapi/app/Http/Controllers/Api/Account/AccountController.php index 85c9b79..c558f8c 100644 --- a/flexiapi/app/Http/Controllers/Api/Account/AccountController.php +++ b/flexiapi/app/Http/Controllers/Api/Account/AccountController.php @@ -187,7 +187,7 @@ class AccountController extends Controller $request->validate([ 'phone' => [ - 'required', new WithoutSpaces, 'starts_with:+' + 'required', new WithoutSpaces, 'starts_with:+', 'exists:accounts,phone' ], 'account_creation_token' => [ 'required', diff --git a/flexiapi/tests/Feature/ApiAccountTest.php b/flexiapi/tests/Feature/ApiAccountTest.php index 0db9efa..4d1438c 100644 --- a/flexiapi/tests/Feature/ApiAccountTest.php +++ b/flexiapi/tests/Feature/ApiAccountTest.php @@ -746,6 +746,12 @@ class ApiAccountTest extends TestCase $token = AccountCreationToken::factory()->create(); + // Wrong phone + $this->json($this->method, $this->route . '/recover-by-phone', [ + 'phone' => '+331234', // wrong phone number + 'account_creation_token' => $token->token + ])->assertJsonValidationErrors(['phone']); + $this->json($this->method, $this->route . '/recover-by-phone', [ 'phone' => $phone, 'account_creation_token' => $token->token