1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 22:22:32 +01:00

Fixes for Twilio

This commit is contained in:
David Bomba 2022-07-27 23:12:36 +10:00
parent 3ee0186c67
commit c8fc1a36a3
3 changed files with 18 additions and 4 deletions

View File

@ -43,9 +43,19 @@ class TwilioController extends BaseController
$twilio = new Client($sid, $token);
$verification = $twilio->verify->v2->services(config('ninja.twilio_verify_sid'))
->verifications
->create($request->phone, "sms");
try {
$verification = $twilio->verify
->v2
->services(config('ninja.twilio_verify_sid'))
->verifications
->create($request->phone, "sms");
}
catch(\Exception $e) {
return response()->json(['message' => 'Phone number format is incorrect, please use international number format and try again.'], 400);
}
$account->account_sms_verification_code = $verification->sid;
$account->account_sms_verification_number = $request->phone;

View File

@ -32,7 +32,7 @@ class GenerateSmsRequest extends Request
{
return [
'phone' => 'required|regex:^\+[1-9]\d{1,14}$',
'phone' => 'required|regex:^\+[1-9]\d{1,14}$^',
];
}

View File

@ -197,4 +197,8 @@ return [
'ninja_apple_client_id' => env('APPLE_CLIENT_ID', false),
'ninja_apple_client_secret' => env('APPLE_CLIENT_SECRET',false),
'ninja_apple_redirect_url' => env('APPLE_REDIRECT_URI',false),
'twilio_account_sid' => env('TWILIO_ACCOUNT_SID',false),
'twilio_auth_token' => env('TWILIO_AUTH_TOKEN',false),
'twilio_verify_sid' => env('TWILIO_VERIFY_SID',false),
];