Merge pull request #6987 from turbo124/v5-develop

Calculate has_password
This commit is contained in:
David Bomba 2021-11-21 13:50:41 +11:00 committed by GitHub
commit ff6f3fc89c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 189 additions and 28 deletions

View File

@ -52,8 +52,6 @@ class Kernel extends ConsoleKernel
$schedule->job(new DiskCleanup)->daily()->withoutOverlapping();
$schedule->command('ninja:check-data --database=db-ninja-01')->daily()->withoutOverlapping();
$schedule->job(new ReminderJob)->hourly()->withoutOverlapping();
$schedule->job(new CompanySizeCheck)->daily()->withoutOverlapping();
@ -84,7 +82,8 @@ class Kernel extends ConsoleKernel
$schedule->job(new AdjustEmailQuota)->dailyAt('23:00')->withoutOverlapping();
$schedule->job(new SendFailedEmails)->daily()->withoutOverlapping();
$schedule->command('ninja:check-data --database=db-ninja-02')->dailyAt('00:15')->withoutOverlapping();
$schedule->command('ninja:check-data --database=db-ninja-01')->daily()->withoutOverlapping();
$schedule->command('ninja:check-data --database=db-ninja-02')->dailyAt('00:05')->withoutOverlapping();
$schedule->command('ninja:s3-cleanup')->dailyAt('23:15')->withoutOverlapping();
}

View File

@ -0,0 +1,67 @@
<?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 App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\Response;
class FilterController extends BaseController
{
private array $base_filters = ['archive', 'restore', 'delete'];
public function __construct()
{
}
/**
* Display a listing of the resource.
*
* @return void
*/
public function index(Request $request, string $entity)
{
$entity_filters = [];
switch ($entity) {
case 'invoice':
$entity_filters = ['bulk_download', 'mark_paid', 'mark_sent', 'download', 'cancel', 'email'];
break;
case 'quote':
$entity_filters = ['bulk_download', 'convert', 'convert_to_invoice', 'download', 'approve', 'email', 'mark_sent'];
break;
case 'credit':
$entity_filters = ['bulk_download', 'download', 'email', 'mark_sent'];
break;
case 'payment':
$entity_filters = ['bulk_download', 'download', 'email', 'email_receipt'];
break;
case 'recurring_invoice':
$entity_filters = ['bulk_download', 'start', 'stop', 'email'];
break;
}
return response()->json( array_merge($this->base_filters, $entity_filters), 200);
}
}

View File

@ -63,29 +63,12 @@ class HostedMigrationController extends Controller
MultiDB::findAndSetDbByCompanyKey($input['account_key']);
$company = Company::with('account')->where('company_key', $input['account_key'])->first();
$account = $company->account;
$client_id = false;
if($contact = ClientContact::on('db-ninja-01')->where(['email' => $input['email'], 'company_id' => config('ninja.ninja_default_company_id')])->first()){
$client_id = $contact->client_id;
}
else if($client = Client::on('db-ninja-01')->where(['custom_value2' => $account->key, 'company_id' => config('ninja.ninja_default_company_id')])->first()){
$client_id = $client->id;
}
//get ninja client_id;
if(strlen($input['gateway_reference']) >1 && $client_id){
Artisan::call('ninja:add-token', [
'--customer' => $input['gateway_reference'], '--client_id' => 1
]);
}
$forward_url = $company->domain();
return response()->json(['forward_url' => $forward_url], 200);
$billing_transferred = \Modules\Admin\Jobs\Account\TransferAccountPlan::dispatchNow($input);
return response()->json(['forward_url' => $forward_url, 'billing_transferred' => $billing_transferred], 200);
}
}

View File

@ -16,6 +16,7 @@ use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
use App\Http\Requests\Gateways\Mollie\Mollie3dsRequest;
use App\Http\Requests\Payments\PaymentWebhookRequest;
use App\Jobs\Util\SystemLogger;
use App\Models\Client;
use App\Models\ClientGatewayToken;
use App\Models\GatewayType;
use App\Models\Invoice;
@ -303,12 +304,38 @@ class MolliePaymentDriver extends BaseDriver
try {
$payment = $this->gateway->payments->get($request->id);
$record = Payment::withTrashed()->where('transaction_reference', $request->id)->first();
$record = Payment::withTrashed()->where('transaction_reference', $request->id)->firstOrFail();
if($record){
$client = $record->client;
}
else{
$client = Client::withTrashed()->find($this->decodePrimaryKey($payment['metadata']->client_id));
}
$message = [
'server_response' => $payment,
'data' => $request->all(),
];
$response = SystemLog::EVENT_GATEWAY_FAILURE;
if($record){
$record->status_id = $codes[$payment->status];
$record->save();
$response = SystemLog::EVENT_GATEWAY_SUCCESS;
}
SystemLogger::dispatch(
$message,
SystemLog::CATEGORY_GATEWAY_RESPONSE,
$response,
SystemLog::TYPE_MOLLIE,
$client
);
return response()->json([], 200);
} catch (ApiException $e) {
return response()->json(['message' => $e->getMessage(), 'gatewayStatusCode' => $e->getCode()], 500);
}

View File

@ -60,7 +60,7 @@ class UserTransformer extends EntityTransformer
'oauth_provider_id' => (string) $user->oauth_provider_id,
'last_confirmed_email_address' => (string) $user->last_confirmed_email_address ?: '',
'google_2fa_secret' => (bool) $user->google_2fa_secret,
'has_password' => (bool) $user->has_password,
'has_password' => (bool) empty($user->password) ? false : true,
'oauth_user_token' => empty($user->oauth_user_token) ? '' : '***',
];
}

View File

@ -38,6 +38,8 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
Route::put('clients/{client}/upload', 'ClientController@upload')->name('clients.upload');
Route::post('clients/bulk', 'ClientController@bulk')->name('clients.bulk');
Route::post('filters/{entity}', 'FilterController@index')->name('filters');
Route::resource('client_gateway_tokens', 'ClientGatewayTokenController');
Route::post('connected_account', 'ConnectedAccountController@index');

View File

@ -0,0 +1,83 @@
<?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://opensource.org/licenses/AAL
*/
namespace Tests\Feature;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Tests\MockAccountData;
use Tests\TestCase;
/**
* @test
* @covers App\Http\Controllers\FilterController
*/
class FilterApiTest extends TestCase
{
use DatabaseTransactions;
use MockAccountData;
public function setUp() :void
{
parent::setUp();
$this->makeTestData();
$this->withoutMiddleware(
ThrottleRequests::class
);
}
public function testActivityGet()
{
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/filters/invoice');
$response->assertStatus(200);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/filters/quote');
$response->assertStatus(200);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/filters/credit');
$response->assertStatus(200);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/filters/payment');
$response->assertStatus(200);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/filters/recurring_invoice');
$response->assertStatus(200);
}
}