mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for verifyphone
This commit is contained in:
parent
270b0106fc
commit
aa206cb406
2
.github/workflows/phpunit.yml
vendored
2
.github/workflows/phpunit.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: ['ubuntu-20.04', 'ubuntu-22.04']
|
operating-system: ['ubuntu-20.04', 'ubuntu-22.04']
|
||||||
php-versions: ['8.1.12']
|
php-versions: ['8.1.11']
|
||||||
phpunit-versions: ['latest']
|
phpunit-versions: ['latest']
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
@ -38,7 +38,7 @@ class HasValidPhoneNumber implements Rule
|
|||||||
$token = config('ninja.twilio_auth_token');
|
$token = config('ninja.twilio_auth_token');
|
||||||
|
|
||||||
if(!$sid)
|
if(!$sid)
|
||||||
return true; // no twilio api credentials provided, bail.
|
return true;
|
||||||
|
|
||||||
$twilio = new Twilio\Rest\Client($sid, $token);
|
$twilio = new Twilio\Rest\Client($sid, $token);
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class VerifyPhone implements ShouldQueue
|
|||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
public function __construct(public User $user){}
|
public function __construct(private User $user){}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
@ -45,7 +45,9 @@ class VerifyPhone implements ShouldQueue
|
|||||||
public function handle() : void
|
public function handle() : void
|
||||||
{
|
{
|
||||||
|
|
||||||
MultiDB::checkUserEmailExists($user->email);
|
MultiDB::checkUserEmailExists($this->user->email);
|
||||||
|
|
||||||
|
$this->user = User::find($this->user);
|
||||||
|
|
||||||
$sid = config('ninja.twilio_account_sid');
|
$sid = config('ninja.twilio_account_sid');
|
||||||
$token = config('ninja.twilio_auth_token');
|
$token = config('ninja.twilio_auth_token');
|
||||||
@ -55,28 +57,28 @@ class VerifyPhone implements ShouldQueue
|
|||||||
|
|
||||||
$twilio = new Twilio\Rest\Client($sid, $token);
|
$twilio = new Twilio\Rest\Client($sid, $token);
|
||||||
|
|
||||||
$country = $user->account?->companies()?->first()?->country();
|
$country = $this->user->account?->companies()?->first()?->country();
|
||||||
|
|
||||||
if(!$country || strlen($user->phone) < 2)
|
if(!$country || strlen($this->user->phone) < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$countryCode = $country->iso_3166_2;
|
$countryCode = $country->iso_3166_2;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
|
||||||
$phone_number = $twilio->lookups->v1->phoneNumbers($user->phone)
|
$phone_number = $twilio->lookups->v1->phoneNumbers($this->user->phone)
|
||||||
->fetch(["countryCode" => $countryCode]);
|
->fetch(["countryCode" => $countryCode]);
|
||||||
}
|
}
|
||||||
catch(\Exception $e) {
|
catch(\Exception $e) {
|
||||||
$user->verified_phone_number = false;
|
$this->user->verified_phone_number = false;
|
||||||
$user->save();
|
$this->user->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($phone_number && strlen($phone_number->phoneNumber) > 1)
|
if($phone_number && strlen($phone_number->phoneNumber) > 1)
|
||||||
{
|
{
|
||||||
$user->phone = $phone_number->phoneNumber;
|
$this->user->phone = $phone_number->phoneNumber;
|
||||||
$user->verified_phone_number = true;
|
$this->user->verified_phone_number = true;
|
||||||
$user->save();
|
$this->user->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user