mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 02:44:29 -04:00
Purge client when cancelling account
This commit is contained in:
parent
86e2c7c8c4
commit
7785f28a26
@ -46,6 +46,7 @@ use Utils;
|
||||
|
||||
use Validator;
|
||||
use View;
|
||||
use App\Jobs\PurgeClientData;
|
||||
|
||||
/**
|
||||
* Class AccountController.
|
||||
@ -389,7 +390,9 @@ class AccountController extends BaseController
|
||||
$planDetails = $account->getPlanDetails(true);
|
||||
$portalLink = false;
|
||||
|
||||
if (Utils::isNinja() && $planDetails && $ninjaClient = $this->accountRepo->getNinjaClient($account)) {
|
||||
if (Utils::isNinja() && $planDetails
|
||||
&& $account->getPrimaryAccount()->id == auth()->user()->account_id
|
||||
&& $ninjaClient = $this->accountRepo->getNinjaClient($account)) {
|
||||
$contact = $ninjaClient->getPrimaryContact();
|
||||
$portalLink = $contact->link;
|
||||
}
|
||||
@ -1459,7 +1462,7 @@ class AccountController extends BaseController
|
||||
$refunded = $company->processRefund(Auth::user());
|
||||
|
||||
$ninjaClient = $this->accountRepo->getNinjaClient($account);
|
||||
$ninjaClient->delete();
|
||||
dispatch(new \App\Jobs\PurgeClientData($ninjaClient));
|
||||
}
|
||||
|
||||
Document::scope()->each(function ($item, $key) {
|
||||
|
@ -46,6 +46,30 @@ class AddSlackNotifications extends Migration
|
||||
$table->foreign('invitation_id')->references('id')->on('invitations')->onDelete('cascade');
|
||||
$table->foreign('expense_id')->references('id')->on('expenses')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::table('companies', function ($table) {
|
||||
$table->dropForeign('companies_payment_id_foreign');
|
||||
});
|
||||
|
||||
Schema::table('companies', function ($table) {
|
||||
$table->index('payment_id');
|
||||
});
|
||||
|
||||
Schema::table('user_accounts', function ($table) {
|
||||
$table->dropForeign('user_accounts_user_id1_foreign');
|
||||
$table->dropForeign('user_accounts_user_id2_foreign');
|
||||
$table->dropForeign('user_accounts_user_id3_foreign');
|
||||
$table->dropForeign('user_accounts_user_id4_foreign');
|
||||
$table->dropForeign('user_accounts_user_id5_foreign');
|
||||
});
|
||||
|
||||
Schema::table('user_accounts', function ($table) {
|
||||
$table->index('user_id1');
|
||||
$table->index('user_id2');
|
||||
$table->index('user_id3');
|
||||
$table->index('user_id4');
|
||||
$table->index('user_id5');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user