mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 00:49:02 +00:00
fix: phone number parsing exception handling
This commit is contained in:
parent
37fc9fdcd3
commit
7315294555
1 changed files with 19 additions and 3 deletions
|
|
@ -28,6 +28,7 @@ use Appwrite\Utopia\Database\Validator\CustomId;
|
|||
use Appwrite\Utopia\Database\Validator\Queries\Identities;
|
||||
use Appwrite\Utopia\Request;
|
||||
use Appwrite\Utopia\Response;
|
||||
use libphonenumber\NumberParseException;
|
||||
use libphonenumber\PhoneNumberUtil;
|
||||
use MaxMind\Db\Reader;
|
||||
use Utopia\Abuse\Abuse;
|
||||
|
|
@ -2467,7 +2468,12 @@ App::post('/v1/account/tokens/phone')
|
|||
$abuse = new Abuse($timelimit);
|
||||
if ($abuse->check() && System::getEnv('_APP_OPTIONS_ABUSE', 'enabled') === 'enabled') {
|
||||
$helper = PhoneNumberUtil::getInstance();
|
||||
$countryCode = $helper->parse($phone)->getCountryCode();
|
||||
|
||||
try {
|
||||
$countryCode = $helper->parse($phone)->getCountryCode();
|
||||
} catch (NumberParseException $e) {
|
||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Invalid phone number');
|
||||
}
|
||||
|
||||
if (!empty($countryCode)) {
|
||||
$queueForUsage
|
||||
|
|
@ -3587,7 +3593,12 @@ App::post('/v1/account/verification/phone')
|
|||
$abuse = new Abuse($timelimit);
|
||||
if ($abuse->check() && System::getEnv('_APP_OPTIONS_ABUSE', 'enabled') === 'enabled') {
|
||||
$helper = PhoneNumberUtil::getInstance();
|
||||
$countryCode = $helper->parse($phone)->getCountryCode();
|
||||
|
||||
try {
|
||||
$countryCode = $helper->parse($phone)->getCountryCode();
|
||||
} catch (NumberParseException $e) {
|
||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Invalid phone number');
|
||||
}
|
||||
|
||||
if (!empty($countryCode)) {
|
||||
$queueForUsage
|
||||
|
|
@ -4148,7 +4159,12 @@ App::post('/v1/account/mfa/challenge')
|
|||
$abuse = new Abuse($timelimit);
|
||||
if ($abuse->check() && System::getEnv('_APP_OPTIONS_ABUSE', 'enabled') === 'enabled') {
|
||||
$helper = PhoneNumberUtil::getInstance();
|
||||
$countryCode = $helper->parse($phone)->getCountryCode();
|
||||
|
||||
try {
|
||||
$countryCode = $helper->parse($phone)->getCountryCode();
|
||||
} catch (NumberParseException $e) {
|
||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Invalid phone number');
|
||||
}
|
||||
|
||||
if (!empty($countryCode)) {
|
||||
$queueForUsage
|
||||
|
|
|
|||
Loading…
Reference in a new issue