mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Default gateway type ID (#3008)
* Show Recurring Invoice - Client Portal * Password protect some routes * Password Protection Routes * Add default_gateway_type_id to gateway table
This commit is contained in:
parent
d29f37ef8b
commit
ed449ea1ab
@ -12,6 +12,7 @@
|
||||
namespace App\Http\Controllers\ClientPortal;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ClientPortal\ShowRecurringInvoiceRequest;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Http\Request;
|
||||
@ -46,7 +47,7 @@ class RecurringInvoiceController extends Controller
|
||||
if (request()->ajax()) {
|
||||
|
||||
return DataTables::of($invoices)->addColumn('action', function ($invoice) {
|
||||
return '<a href="/client/recurring_invoices/'. $invoice->hashed_id .'/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.view').'</a>';
|
||||
return '<a href="/client/recurring_invoices/'. $invoice->hashed_id .'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.view').'</a>';
|
||||
})->addColumn('frequency_id', function ($invoice) {
|
||||
return RecurringInvoice::frequencyForKey($invoice->frequency_id);
|
||||
})
|
||||
@ -71,10 +72,14 @@ class RecurringInvoiceController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(RecurringInvoice $invoice)
|
||||
public function show(ShowRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
|
||||
{
|
||||
|
||||
|
||||
$data = [
|
||||
'invoice' => $recurring_invoice->load('invoices'),
|
||||
];
|
||||
|
||||
return view('portal.default.recurring_invoices.show', $data);
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,6 +105,7 @@ class Kernel extends HttpKernel
|
||||
'contact_token_auth' => \App\Http\Middleware\ContactTokenAuth::class,
|
||||
'contact_db' => \App\Http\Middleware\ContactSetDb::class,
|
||||
'domain_db' => \App\Http\Middleware\SetDomainNameDb::class,
|
||||
'password_protected' => \App\Http\Middleware\PasswordProtection::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
];
|
||||
}
|
||||
|
62
app/Http/Middleware/PasswordProtection.php
Normal file
62
app/Http/Middleware/PasswordProtection.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\CompanyToken;
|
||||
use Closure;
|
||||
|
||||
class PasswordProtection
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
|
||||
$error = [
|
||||
'message' => 'Invalid Password',
|
||||
'errors' => []
|
||||
];
|
||||
|
||||
if( $request->header('X-API-PASSWORD') )
|
||||
{
|
||||
|
||||
if(!Hash::check($request->header('X-API-PASSWORD'), auth()->user()->password))
|
||||
return response()->json($error, 403);
|
||||
|
||||
}
|
||||
elseif (Cache::get(auth()->user()->email."_logged_in")) {
|
||||
return $next($request);
|
||||
}
|
||||
else {
|
||||
|
||||
$error = [
|
||||
'message' => 'Access denied',
|
||||
'errors' => []
|
||||
];
|
||||
return response()->json($error, 412);
|
||||
|
||||
}
|
||||
|
||||
Cache::add(auth()->user()->email."_logged_in", 'logged_in', now()->addMinutes(5));
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests\ClientPortal;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\Invoice;
|
||||
|
||||
class ShowRecurringInvoiceRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
public function authorize() : bool
|
||||
{
|
||||
return auth()->user()->client->id === $this->recurring_invoice->client_id;
|
||||
}
|
||||
|
||||
}
|
@ -121,7 +121,7 @@ class CreateInvoicePdf implements ShouldQueue
|
||||
$data['__env'] = app(\Illuminate\View\Factory::class);
|
||||
|
||||
$php = Blade::compileString($string);
|
||||
//Log::error($php);
|
||||
|
||||
$obLevel = ob_get_level();
|
||||
ob_start();
|
||||
extract($data, EXTR_SKIP);
|
||||
|
@ -107,12 +107,9 @@ class BaseModel extends Model
|
||||
/* Does Setting Exist @ client level */
|
||||
if(isset($this->getSettings()->{$key}))
|
||||
{
|
||||
//Log::error('harvesting client settings for key = '. $key . ' and it has the value = '. $this->getSettings()->{$key});
|
||||
//Log::error(print_r($this->getSettings(),1));
|
||||
return $this->getSettings()->{$key};
|
||||
}
|
||||
else {
|
||||
//Log::error(print_r(new CompanySettings($this->company->settings),1));
|
||||
return (new CompanySettings($this->company->settings))->{$key};
|
||||
}
|
||||
|
||||
@ -123,13 +120,13 @@ class BaseModel extends Model
|
||||
{
|
||||
switch ($entity) {
|
||||
case Client::class:
|
||||
// Log::error('saving client settings');
|
||||
|
||||
$this->settings = $settings;
|
||||
$this->save();
|
||||
$this->fresh();
|
||||
break;
|
||||
case Company::class:
|
||||
// Log::error('saving company settings');
|
||||
|
||||
$this->company->settings = $settings;
|
||||
$this->company->save();
|
||||
break;
|
||||
|
@ -222,8 +222,6 @@ class Client extends BaseModel
|
||||
}
|
||||
|
||||
/*Company Settings*/
|
||||
// \Log::error($setting);
|
||||
// \Log::error(print_r($this->company->settings,1));
|
||||
if((property_exists($this->company->settings, $setting) != false ) && (isset($this->company->settings->{$setting}) !== false) ){
|
||||
return $this->company->settings->{$setting};
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ class Gateway extends StaticModel
|
||||
'visible' => 'boolean',
|
||||
'updated_at' => 'timestamp',
|
||||
'created_at' => 'timestamp',
|
||||
'default_gateway_type_id' => 'string',
|
||||
'fields' => 'json',
|
||||
];
|
||||
|
||||
|
@ -37,7 +37,6 @@ class PaymentTerm extends BaseModel
|
||||
|
||||
public static function getCompanyTerms()
|
||||
{
|
||||
//Log::error('getting company terms');
|
||||
$default_terms = collect(config('ninja.payment_terms'));
|
||||
|
||||
$terms = self::scope()->get();
|
||||
|
@ -110,6 +110,11 @@ class RecurringInvoice extends BaseModel
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany(Invoice::class, "id", "recurring_invoice_id");
|
||||
}
|
||||
|
||||
public function invitations()
|
||||
{
|
||||
$this->morphMany(RecurringInvoiceInvitation::class);
|
||||
|
@ -155,7 +155,6 @@ class MultiDatabaseUserProvider implements UserProvider
|
||||
*/
|
||||
public function validateCredentials(UserContract $user, array $credentials)
|
||||
{
|
||||
//Log::error('validateCredentials');
|
||||
|
||||
$plain = $credentials['password'];
|
||||
|
||||
|
@ -33,8 +33,6 @@ class ActivityRepository extends BaseRepository
|
||||
|
||||
$activity->is_system = app()->runningInConsole();
|
||||
$activity->ip = request()->getClientIp();
|
||||
//Log::error($activity);
|
||||
//Log::error($entity);
|
||||
|
||||
foreach($fields as $key => $value) {
|
||||
|
||||
|
@ -373,9 +373,6 @@ trait GeneratesCounter
|
||||
|
||||
$search[] = '{$id_number}';
|
||||
$replace[] = $client->id_number;
|
||||
//Log::error($search);
|
||||
//Log::error($replace);
|
||||
//Log::error($pattern);
|
||||
|
||||
return str_replace($search, $replace, $pattern);
|
||||
|
||||
|
@ -176,8 +176,4 @@ trait SettingsSaver
|
||||
}
|
||||
}
|
||||
|
||||
// \Log::error('popping '.$key.' '.$value.' '.$settings->{$key}.' off the stack');
|
||||
// \Log::error('popping '.$key.' '.$value.' '.$settings->{$key}.' off the stack');
|
||||
// s\Log::error("integer testing {$key} - {$value} - ".$settings->{$key});
|
||||
|
||||
}
|
@ -88,6 +88,7 @@ class CreateUsersTable extends Migration
|
||||
$table->boolean('is_offsite')->default(false);
|
||||
$table->boolean('is_secure')->default(false);
|
||||
$table->text('fields')->nullable();
|
||||
$table->unsignedInteger('default_gateway_type_id')->default(1);
|
||||
$table->timestamps(6);
|
||||
});
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
@extends('portal.default.layouts.master')
|
||||
@section('header')
|
||||
@stop
|
||||
@section('body')
|
||||
<main class="main">
|
||||
<div class="container-fluid">
|
||||
<div class="row" style="padding-top: 30px;">
|
||||
<div class="col d-flex justify-content-center">
|
||||
<div class="card w-50 p-10">
|
||||
<div class="card-header">
|
||||
{{ ctrans('texts.recurring_invoice')}}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-responsive-sm table-bordered">
|
||||
<tr><td style="text-align: right;">{{ctrans('texts.start_date')}}</td><td>{!! $invoice->start_date !!}</td></tr>
|
||||
<tr><td style="text-align: right;">{{ctrans('texts.next_send_date')}}</td><td>{!! $invoice->next_send_date !!}</td></tr>
|
||||
<tr><td style="text-align: right;">{{ctrans('texts.frequency')}}</td><td>{!! App\Models\RecurringInvoice::frequencyForKey($invoice->frequency_id) !!}</td></tr>
|
||||
<tr><td style="text-align: right;">{{ctrans('texts.cycles_remaining')}}</td><td>{!! $invoice->remaining_cycles !!}</td></tr>
|
||||
<tr><td style="text-align: right;">{{ctrans('texts.amount')}}</td><td>{!! $invoice->amount !!}</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<table class="table table-responsive-sm table-sm">
|
||||
@foreach($invoice->invoices as $inv)
|
||||
{{ $inv->id }} - {{ $inv->amount }}
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
</body>
|
||||
@endsection
|
||||
@push('css')
|
||||
@endpush
|
||||
@push('scripts')
|
||||
@endpush
|
||||
@section('footer')
|
||||
@endsection
|
||||
|
@ -68,9 +68,9 @@ Route::group(['middleware' => ['api_db','api_secret_check','token_auth'], 'prefi
|
||||
|
||||
Route::post('payments/bulk', 'PaymentController@bulk')->name('payments.bulk');
|
||||
|
||||
Route::resource('users', 'UserController'); // name = (users. index / create / show / update / destroy / edit
|
||||
Route::resource('users', 'UserController')->middleware('password_protected'); // name = (users. index / create / show / update / destroy / edit
|
||||
|
||||
Route::post('users/bulk', 'UserController@bulk')->name('users.bulk');
|
||||
Route::post('users/bulk', 'UserController@bulk')->name('users.bulk')->middleware('password_protected');
|
||||
|
||||
Route::resource('companies', 'CompanyController'); // name = (companies. index / create / show / update / destroy / edit
|
||||
|
||||
|
@ -22,6 +22,7 @@ Route::group(['middleware' => ['auth:contact'], 'prefix' => 'client', 'as' => 'c
|
||||
Route::get('invoices/{invoice_invitation}', 'ClientPortal\InvoiceController@show')->name('invoice.show_invitation');
|
||||
|
||||
Route::get('recurring_invoices', 'ClientPortal\RecurringInvoiceController@index')->name('recurring_invoices.index');
|
||||
Route::get('recurring_invoices/{recurring_invoice}', 'ClientPortal\RecurringInvoiceController@show')->name('recurring_invoices.show');
|
||||
|
||||
Route::get('payments', 'ClientPortal\PaymentController@index')->name('payments.index');
|
||||
Route::get('payments/{payment}', 'ClientPortal\PaymentController@show')->name('payments.show');
|
||||
|
@ -46,12 +46,10 @@ class MarkInvoicePaidTest extends TestCase
|
||||
$this->assertEquals(1, count($invoice->payments));
|
||||
|
||||
foreach($invoice->payments as $payment) {
|
||||
//Log::error($payment);
|
||||
$this->assertEquals($this->invoice->amount, $payment->amount);
|
||||
}
|
||||
|
||||
//events are not firing which makes this impossible to control.
|
||||
// $this->assertEquals(Invoice::STATUS_PAID, $invoice->status_id);
|
||||
|
||||
$this->assertEquals(0.00, $invoice->balance);
|
||||
|
||||
|
@ -110,7 +110,6 @@ class UploadLogoTest extends TestCase
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
//Log::error(print_r($response->json(),1));
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user