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

rate limiting for hosteD

This commit is contained in:
David Bomba 2023-05-05 14:15:50 +10:00
parent 430d42b2e0
commit 173fd42cbf
3 changed files with 12 additions and 9 deletions

View File

@ -79,7 +79,7 @@ class Handler extends ExceptionHandler
/** /**
* A list of the inputs that are never flashed for validation exceptions. * A list of the inputs that are never flashed for validation exceptions.
* *
* @var array * @var array<1, string>
*/ */
protected $dontFlash = [ protected $dontFlash = [
'current_password', 'current_password',
@ -102,6 +102,11 @@ class Handler extends ExceptionHandler
} }
if (Ninja::isHosted()) { if (Ninja::isHosted()) {
if($exception instanceof ThrottleRequestsException && class_exists(\Modules\Admin\Events\ThrottledExceptionRaised::class)) {
event(new \Modules\Admin\Events\ThrottledExceptionRaised(auth()->user()->account->key));
}
Integration::configureScope(function (Scope $scope): void { Integration::configureScope(function (Scope $scope): void {
$name = 'hosted@invoiceninja.com'; $name = 'hosted@invoiceninja.com';
@ -202,7 +207,6 @@ class Handler extends ExceptionHandler
* *
* @param Request $request * @param Request $request
* @param Throwable $exception * @param Throwable $exception
* @return Response
* @throws Throwable * @throws Throwable
*/ */
public function render($request, Throwable $exception) public function render($request, Throwable $exception)

View File

@ -518,12 +518,6 @@ class NinjaMailerJob implements ShouldQueue
/* If the account is verified, we allow emails to flow */ /* If the account is verified, we allow emails to flow */
if (Ninja::isHosted() && $this->company->account && $this->company->account->is_verified_account) { if (Ninja::isHosted() && $this->company->account && $this->company->account->is_verified_account) {
//11-01-2022
/* Continue to analyse verified accounts in case they later start sending poor quality emails*/
// if(class_exists(\Modules\Admin\Jobs\Account\EmailQuality::class))
// (new \Modules\Admin\Jobs\Account\EmailQuality($this->nmo, $this->company))->run();
return false; return false;
} }

View File

@ -64,7 +64,7 @@ use Laracasts\Presenter\PresentableTrait;
* @property int|null $hosted_company_count * @property int|null $hosted_company_count
* @property string|null $inapp_transaction_id * @property string|null $inapp_transaction_id
* @property bool $set_react_as_default_ap * @property bool $set_react_as_default_ap
* @property int $is_flagged * @property bool $is_flagged
* @property int $is_verified_account * @property int $is_verified_account
* @property string|null $account_sms_verification_code * @property string|null $account_sms_verification_code
* @property string|null $account_sms_verification_number * @property string|null $account_sms_verification_number
@ -262,6 +262,11 @@ class Account extends BaseModel
return $this->hasMany(CompanyUser::class)->where('is_owner', true)->first() ? $this->hasMany(CompanyUser::class)->where('is_owner', true)->first()->user : false; return $this->hasMany(CompanyUser::class)->where('is_owner', true)->first() ? $this->hasMany(CompanyUser::class)->where('is_owner', true)->first()->user : false;
} }
public function tokens()
{
return $this->hasMany(CompanyToken::class)->withTrashed();
}
public function getPlan() public function getPlan()
{ {
if (Carbon::parse($this->plan_expires)->lt(now())) { if (Carbon::parse($this->plan_expires)->lt(now())) {