mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 03:54:36 -04:00
Add SMS checks
This commit is contained in:
parent
8a54df3cf6
commit
80b944f822
88381
app/DataProviders/SMSNumbers.php
Normal file
88381
app/DataProviders/SMSNumbers.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Http\Requests\CompanyGateway;
|
||||||
|
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class TestCompanyGatewayRequest extends Request
|
||||||
|
{
|
||||||
|
use MakesHash;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
return $user->isAdmin();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function prepareForValidation()
|
||||||
|
{
|
||||||
|
$input = $this->all();
|
||||||
|
|
||||||
|
$this->replace($input);
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@
|
|||||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
*
|
*1`
|
||||||
* @license https://www.elastic.co/licensing/elastic-license
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ class NinjaMailerJob implements ShouldQueue
|
|||||||
|
|
||||||
private function incrementEmailCounter(): void
|
private function incrementEmailCounter(): void
|
||||||
{
|
{
|
||||||
if(in_array($this->mailer, ['default','mailgun']))
|
if(in_array($this->mailer, ['default','mailgun','postmark']))
|
||||||
Cache::increment("email_quota".$this->company->account->key);
|
Cache::increment("email_quota".$this->company->account->key);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ use Illuminate\Support\Str;
|
|||||||
use App\Models\CompanyToken;
|
use App\Models\CompanyToken;
|
||||||
use App\Models\ClientContact;
|
use App\Models\ClientContact;
|
||||||
use App\Models\VendorContact;
|
use App\Models\VendorContact;
|
||||||
|
use App\DataProviders\SMSNumbers;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -537,6 +538,10 @@ class MultiDB
|
|||||||
|
|
||||||
$current_db = config('database.default');
|
$current_db = config('database.default');
|
||||||
|
|
||||||
|
if(SMSNumbers::numberExists($phone)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (self::$dbs as $db) {
|
foreach (self::$dbs as $db) {
|
||||||
self::setDB($db);
|
self::setDB($db);
|
||||||
if ($exists = Account::where('account_sms_verification_number', $phone)->where('account_sms_verified', true)->exists()) {
|
if ($exists = Account::where('account_sms_verification_number', $phone)->where('account_sms_verified', true)->exists()) {
|
||||||
|
@ -246,7 +246,7 @@ class Email implements ShouldQueue
|
|||||||
|
|
||||||
private function incrementEmailCounter(): void
|
private function incrementEmailCounter(): void
|
||||||
{
|
{
|
||||||
if(in_array($this->mailer, ['default','mailgun']))
|
if(in_array($this->mailer, ['default','mailgun','postmark']))
|
||||||
Cache::increment("email_quota".$this->company->account->key);
|
Cache::increment("email_quota".$this->company->account->key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
36
tests/Unit/SmsNumberTest.php
Normal file
36
tests/Unit/SmsNumberTest.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\Unit;
|
||||||
|
|
||||||
|
use App\DataProviders\SMSNumbers;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
class SmsNumberTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testArrayHit()
|
||||||
|
{
|
||||||
|
$this->assertTrue(SMSNumbers::hasNumber("+461614222"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testArrayMiss()
|
||||||
|
{
|
||||||
|
$this->assertFalse(SMSNumbers::hasNumber("+5485454"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSmsArrayType()
|
||||||
|
{
|
||||||
|
$this->assertIsArray(SMSNumbers::getNumbers());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user