mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01: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:
|
||||
matrix:
|
||||
operating-system: ['ubuntu-20.04', 'ubuntu-22.04']
|
||||
php-versions: ['8.1.12']
|
||||
php-versions: ['8.1.11']
|
||||
phpunit-versions: ['latest']
|
||||
|
||||
env:
|
||||
|
@ -38,7 +38,7 @@ class HasValidPhoneNumber implements Rule
|
||||
$token = config('ninja.twilio_auth_token');
|
||||
|
||||
if(!$sid)
|
||||
return true; // no twilio api credentials provided, bail.
|
||||
return true;
|
||||
|
||||
$twilio = new Twilio\Rest\Client($sid, $token);
|
||||
|
||||
|
@ -35,7 +35,7 @@ class VerifyPhone implements ShouldQueue
|
||||
*
|
||||
* @param User $user
|
||||
*/
|
||||
public function __construct(public User $user){}
|
||||
public function __construct(private User $user){}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
@ -45,7 +45,9 @@ class VerifyPhone implements ShouldQueue
|
||||
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');
|
||||
$token = config('ninja.twilio_auth_token');
|
||||
@ -55,28 +57,28 @@ class VerifyPhone implements ShouldQueue
|
||||
|
||||
$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;
|
||||
|
||||
$countryCode = $country->iso_3166_2;
|
||||
|
||||
try{
|
||||
|
||||
$phone_number = $twilio->lookups->v1->phoneNumbers($user->phone)
|
||||
$phone_number = $twilio->lookups->v1->phoneNumbers($this->user->phone)
|
||||
->fetch(["countryCode" => $countryCode]);
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
$user->verified_phone_number = false;
|
||||
$user->save();
|
||||
$this->user->verified_phone_number = false;
|
||||
$this->user->save();
|
||||
}
|
||||
|
||||
if($phone_number && strlen($phone_number->phoneNumber) > 1)
|
||||
{
|
||||
$user->phone = $phone_number->phoneNumber;
|
||||
$user->verified_phone_number = true;
|
||||
$user->save();
|
||||
$this->user->phone = $phone_number->phoneNumber;
|
||||
$this->user->verified_phone_number = true;
|
||||
$this->user->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user