diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index d9361ef0b0b0..0d0420db0884 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -26,6 +26,13 @@ class CompanySettings extends BaseSettings public $auto_archive_invoice = false; public $lock_sent_invoices = false; + public $enable_client_portal_tasks = false; + public $enable_client_portal_password = false; + public $enable_client_portal = true; //implemented + public $enable_client_portal_dashboard = true; //implemented + public $signature_on_pdf = false; + public $document_email_attachment = false; + public $send_portal_password = false; public $timezone_id = ''; public $date_format_id = ''; @@ -52,7 +59,6 @@ class CompanySettings extends BaseSettings public $payment_terms = 1; public $send_reminders = false; - public $show_tasks_in_portal = false; public $custom_message_dashboard = ''; public $custom_message_unpaid_invoice = ''; @@ -62,6 +68,7 @@ class CompanySettings extends BaseSettings public $auto_convert_quote = false; public $inclusive_taxes = false; + public $quote_footer = ''; public $translations; @@ -104,7 +111,7 @@ class CompanySettings extends BaseSettings public $shared_invoice_quote_counter = false; - public $recurring_invoice_number_prefix = 'R'; + public $recurring_number_prefix = 'R'; public $reset_counter_frequency_id = '0'; public $reset_counter_date = ''; public $counter_padding = 4; @@ -130,7 +137,6 @@ class CompanySettings extends BaseSettings public $custom_fields = ''; public $invoice_fields = ''; - public $enable_portal_password = false; public $show_accept_invoice_terms = false; public $show_accept_quote_terms = false; public $require_invoice_signature = false; @@ -147,9 +153,11 @@ class CompanySettings extends BaseSettings public $email_subject_invoice = ''; public $email_subject_quote = ''; public $email_subject_payment = ''; + public $email_subject_statement = ''; public $email_template_invoice = ''; public $email_template_quote = ''; public $email_template_payment = ''; + public $email_template_statement = ''; public $email_subject_reminder1 = ''; public $email_subject_reminder2 = ''; public $email_subject_reminder3 = ''; @@ -158,7 +166,8 @@ class CompanySettings extends BaseSettings public $email_template_reminder2 = ''; public $email_template_reminder3 = ''; public $email_template_reminder_endless = ''; - public $email_footer = ''; + public $email_signature = ''; + public $enable_email_markup = true; /* Company Meta data that we can use to build sub companies*/ @@ -187,6 +196,16 @@ class CompanySettings extends BaseSettings public static $casts = [ + 'document_email_attachment' => 'bool', + 'enable_client_portal_password' => 'bool', + 'enable_email_markup' => 'bool', + 'enable_client_portal_dashboard' => 'bool', + 'enable_client_portal' => 'bool', + 'email_template_statement' => 'string', + 'email_subject_statement' => 'string', + 'signature_on_pdf' => 'bool', + 'send_portal_password' => 'bool', + 'quote_footer' => 'string', 'page_size' => 'string', 'font_size' => 'int', 'primary_font' => 'string', @@ -243,7 +262,7 @@ class CompanySettings extends BaseSettings 'custom_message_unapproved_quote' => 'string', 'custom_fields' => 'string', 'default_task_rate' => 'float', - 'email_footer' => 'string', + 'email_signature' => 'string', 'email_subject_invoice' => 'string', 'email_subject_quote' => 'string', 'email_subject_payment' => 'string', @@ -258,7 +277,7 @@ class CompanySettings extends BaseSettings 'email_template_reminder2' => 'string', 'email_template_reminder3' => 'string', 'email_template_reminder_endless' => 'string', - 'enable_portal_password' => 'bool', + 'enable_client_portal_password' => 'bool', 'inclusive_taxes' => 'bool', 'invoice_number_prefix' => 'string', 'invoice_number_pattern' => 'string', @@ -280,7 +299,7 @@ class CompanySettings extends BaseSettings 'quote_number_pattern' => 'string', 'quote_number_counter' => 'integer', 'quote_terms' => 'string', - 'recurring_invoice_number_prefix' => 'string', + 'recurring_number_prefix' => 'string', 'reset_counter_frequency_id' => 'integer', 'reset_counter_date' => 'string', 'require_invoice_signature' => 'bool', @@ -304,7 +323,7 @@ class CompanySettings extends BaseSettings 'language_id' => 'string', 'show_currency_code' => 'bool', 'send_reminders' => 'bool', - 'show_tasks_in_portal' => 'bool', + 'enable_client_portal_tasks' => 'bool', 'lock_sent_invoices' => 'bool', 'auto_archive_invoice' => 'bool', 'auto_archive_quote' => 'bool', diff --git a/app/Http/Controllers/Auth/ContactLoginController.php b/app/Http/Controllers/Auth/ContactLoginController.php index 812d09bef742..19db5828a23d 100644 --- a/app/Http/Controllers/Auth/ContactLoginController.php +++ b/app/Http/Controllers/Auth/ContactLoginController.php @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; +use App\Models\ClientContact; use Auth; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; @@ -26,7 +27,7 @@ class ContactLoginController extends Controller public function __construct() { - $this->middleware('guest:contact', ['except' => ['logout']]); + $this->middleware('guest:contact', ['except' => ['logout']]); } public function showLoginForm() @@ -60,7 +61,16 @@ class ContactLoginController extends Controller return $this->sendFailedLoginResponse($request); } + public function authenticated(Request $request, ClientContact $client) + { + + Auth::guard('contact')->login($client, true); + if(session()->get('url.intended')) + return redirect(session()->get('url.intended')); + + return redirect()->intended(); + } public function logout() { diff --git a/app/Http/Controllers/ClientPortal/InvitationController.php b/app/Http/Controllers/ClientPortal/InvitationController.php index baa95d7aa9c3..e7e9aba211ad 100644 --- a/app/Http/Controllers/ClientPortal/InvitationController.php +++ b/app/Http/Controllers/ClientPortal/InvitationController.php @@ -32,13 +32,19 @@ class InvitationController extends Controller public function invoiceRouter(string $invitation_key) { -// $invitation = InvoiceInvitation::whereInvitationKey($invitation_key)->first(); $invitation = InvoiceInvitation::whereRaw("BINARY `invitation_key`= ?", [$invitation_key])->first(); if($invitation){ - $invitation->markViewed(); - Auth::guard('contact')->loginUsingId($invitation->client_contact_id, true); - return redirect()->route('client.invoice.show', ['invoice' => $this->encodePrimaryKey($invitation->invoice_id)]); + +\Log::error("bool val = ".boolval($invitation->contact->client->getSetting('enable_client_portal_password'))); + + if((bool)$invitation->contact->client->getSetting('enable_client_portal_password') !== false) + $this->middleware('auth:contact'); + + $invitation->markViewed(); + + return redirect()->route('client.invoice.show', ['invoice' => $this->encodePrimaryKey($invitation->invoice_id)]); + } else abort(404); diff --git a/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php b/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php index 51a77f2e90be..399b26f023c3 100644 --- a/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php +++ b/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php @@ -17,6 +17,7 @@ use App\Models\RecurringInvoice; use App\Utils\Traits\MakesHash; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; +use Illuminate\Support\Facades\Mail; use Yajra\DataTables\Facades\DataTables; use Yajra\DataTables\Html\Builder; @@ -80,8 +81,24 @@ class RecurringInvoiceController extends Controller ]; return view('portal.default.recurring_invoices.show', $data); + } + public function requestCancellation(Request $request, RecurringInvoice $recurring_invoice) + { + + $data = [ + 'invoice' => $recurring_invoice + ]; + + //todo double check the user is able to request a cancellation + + Mail::to(config('ninja.contact.ninja_official_contact')) + ->send(new RecurringCancellationRequest($invoice)); + + return view('portal.default.recurring_invoices.request_cancellation', $data); + + } } diff --git a/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php b/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php index 8b8aa64940ec..bf1a36291320 100644 --- a/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php +++ b/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php @@ -21,7 +21,7 @@ * @OA\Property(property="custom_invoice_taxes4", type="boolean", example=true, description="____________"), * @OA\Property(property="default_task_rate", type="number", format="float", example="10.00", description="____________"), * @OA\Property(property="send_reminders", type="boolean", example=true, description="____________"), - * @OA\Property(property="show_tasks_in_portal", type="boolean", example=true, description="____________"), + * @OA\Property(property="enable_client_portal_tasks", type="boolean", example=true, description="____________"), * @OA\Property(property="email_style", type="string", example="light", description="options include plain,light,dark,custom"), * @OA\Property(property="reply_to_email", type="string", example="email@gmail.com", description="The reply to email address"), * @OA\Property(property="bcc_email", type="string", example="email@gmail.com, contact@gmail.com", description="A comma separate list of BCC emails"), @@ -134,6 +134,16 @@ * @OA\Property(property="embed_documents", type="boolean", example=false, description="____________"), * @OA\Property(property="all_pages_header", type="boolean", example=false, description="____________"), * @OA\Property(property="all_pages_footer", type="boolean", example=false, description="____________"), + * @OA\Property(property="document_email_attachment", type="boolean", example=false, description="____________"), + * @OA\Property(property="enable_client_portal_password", type="boolean", example=false, description="____________"), + * @OA\Property(property="enable_email_markup", type="boolean", example=false, description="____________"), + * @OA\Property(property="enable_client_portal_dashboard", type="boolean", example=false, description="____________"), + * @OA\Property(property="enable_client_portal", type="boolean", example=false, description="____________"), + * @OA\Property(property="email_template_statement", type="string", example='template matter', description="____________"), + * @OA\Property(property="email_subject_statement", type="string", example='subject matter', description="____________"), + * @OA\Property(property="signature_on_pdf", type="boolean", example=false, description="____________"), + * @OA\Property(property="send_portal_password", type="boolean", example=false, description="____________"), + * @OA\Property(property="quote_footer", type="string", example='the quote footer', description="____________"), * ) */ diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 39f21d3ea48f..e0093a2fb7af 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -107,5 +107,6 @@ class Kernel extends HttpKernel 'domain_db' => \App\Http\Middleware\SetDomainNameDb::class, 'password_protected' => \App\Http\Middleware\PasswordProtection::class, 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, + 'portal_enabled' => \App\Http\Middleware\ClientPortalEnabled::class, ]; } diff --git a/app/Http/Middleware/ClientPortalEnabled.php b/app/Http/Middleware/ClientPortalEnabled.php new file mode 100644 index 000000000000..778f8dcd4e9e --- /dev/null +++ b/app/Http/Middleware/ClientPortalEnabled.php @@ -0,0 +1,36 @@ +user()->client->getSetting('enable_client_portal') === false) + return redirect()->to('client/dashboard'); + + + return $next($request); + + } +} diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index e08c408453f9..da284e3bb176 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -29,7 +29,7 @@ class RedirectIfAuthenticated switch ($guard) { case 'contact': if (Auth::guard($guard)->check()) { - return redirect()->route('client.dashboard'); + return redirect()->route('client.dashboard'); } break; case 'user': diff --git a/app/Http/ViewComposers/PortalComposer.php b/app/Http/ViewComposers/PortalComposer.php index 4a11f780af35..84e36381e42a 100644 --- a/app/Http/ViewComposers/PortalComposer.php +++ b/app/Http/ViewComposers/PortalComposer.php @@ -49,6 +49,9 @@ class PortalComposer $data['countries'] = TranslationHelper::getCountries(); $data['company'] = auth()->user()->company; $data['client'] = auth()->user()->client; + $data['settings'] = auth()->user()->client->getMergedSettings(); + +//\Log::error(print_r($data['settings'],1)); return $data; diff --git a/app/Jobs/Account/CreateAccount.php b/app/Jobs/Account/CreateAccount.php index bb11901f396d..8cf0a1878f74 100644 --- a/app/Jobs/Account/CreateAccount.php +++ b/app/Jobs/Account/CreateAccount.php @@ -17,11 +17,13 @@ use App\Jobs\Company\CreateCompanyToken; use App\Jobs\User\CreateUser; use App\Models\Account; use App\Models\User; +use App\Notifications\NewAccountCreated; use App\Utils\Traits\UserSessionAttributes; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; +use Illuminate\Support\Facades\Notification; class CreateAccount { @@ -89,6 +91,9 @@ class CreateAccount if($user) event(new AccountCreated($user)); + Notification::route('slack', config('ninja.notification.slack')) + ->notify(new NewAccountCreated($user, $company)); + return $account; } } diff --git a/app/Jobs/User/CreateUser.php b/app/Jobs/User/CreateUser.php index b79f738370d0..764a56af1fbc 100644 --- a/app/Jobs/User/CreateUser.php +++ b/app/Jobs/User/CreateUser.php @@ -62,6 +62,7 @@ class CreateUser $user->fill($this->request); $user->email = $this->request['email'];//todo need to remove this in production $user->last_login = now(); + $user->ip = request()->ip(); $user->save(); $user->companies()->attach($this->company->id, [ diff --git a/app/Mail/RecurringCancellationRequest.php b/app/Mail/RecurringCancellationRequest.php new file mode 100644 index 000000000000..5af596937821 --- /dev/null +++ b/app/Mail/RecurringCancellationRequest.php @@ -0,0 +1,35 @@ +recurring_invoice = $recurring_invoice + } + + /** + * Build the message. + * + * @return $this + */ + public function build() + { + return $this->view('view.name'); + } +} diff --git a/app/Mail/SupportMessageSent.php b/app/Mail/SupportMessageSent.php index b4b4b89d3da7..2a95599427aa 100644 --- a/app/Mail/SupportMessageSent.php +++ b/app/Mail/SupportMessageSent.php @@ -47,7 +47,7 @@ class SupportMessageSent extends Mailable $log_lines = iterator_to_array($lines); } - return $this->from(config('mail.from.address')) + return $this->from(config('mail.from.address')) //todo this needs to be fixed to handle the hosted version ->subject(ctrans('texts.new_support_message')) ->markdown('email.support.message', [ 'message' => $this->message, diff --git a/app/Models/ClientContact.php b/app/Models/ClientContact.php index fd1bc386d8fe..8e6c337c2358 100644 --- a/app/Models/ClientContact.php +++ b/app/Models/ClientContact.php @@ -12,20 +12,22 @@ namespace App\Models; use App\Models\Company; +use App\Models\Language; use App\Models\User; use App\Notifications\ClientContactResetPassword as ResetPasswordNotification; use App\Notifications\ClientContactResetPassword; use App\Utils\Traits\MakesHash; use Hashids\Hashids; use Illuminate\Contracts\Auth\MustVerifyEmail; +use Illuminate\Contracts\Translation\HasLocalePreference; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; -use Laracasts\Presenter\PresentableTrait; use Illuminate\Support\Facades\Log; +use Laracasts\Presenter\PresentableTrait; -class ClientContact extends Authenticatable +class ClientContact extends Authenticatable implements HasLocalePreference { use Notifiable; use MakesHash; @@ -133,4 +135,11 @@ class ClientContact extends Authenticatable { $this->notify(new ClientContactResetPassword($token)); } + + public function preferredLocale() + { + $lang = Language::find($this->client->getSetting('language_id')); + + return $lang->locale; + } } diff --git a/app/Models/InvoiceInvitation.php b/app/Models/InvoiceInvitation.php index a648329a581c..b7669468623b 100644 --- a/app/Models/InvoiceInvitation.php +++ b/app/Models/InvoiceInvitation.php @@ -43,7 +43,7 @@ class InvoiceInvitation extends BaseModel */ public function contact() { - return $this->belongsTo(ClientContact::class)->withTrashed(); + return $this->belongsTo(ClientContact::class,'client_contact_id','id')->withTrashed(); } /** diff --git a/app/Models/User.php b/app/Models/User.php index 6b6d32a65d55..f446fe411d55 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -15,11 +15,13 @@ use App\Models\Company; use App\Models\CompanyToken; use App\Models\CompanyUser; use App\Models\Filterable; +use App\Models\Language; use App\Models\Traits\UserTrait; use App\Utils\Traits\MakesHash; use App\Utils\Traits\UserSessionAttributes; use App\Utils\Traits\UserSettings; use Illuminate\Contracts\Auth\MustVerifyEmail; +use Illuminate\Contracts\Translation\HasLocalePreference; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; @@ -28,7 +30,7 @@ use Illuminate\Support\Collection; use Illuminate\Support\Facades\Log; use Laracasts\Presenter\PresentableTrait; -class User extends Authenticatable implements MustVerifyEmail +class User extends Authenticatable implements MustVerifyEmail,HasLocalePreference { use Notifiable; use SoftDeletes; @@ -62,8 +64,8 @@ class User extends Authenticatable implements MustVerifyEmail protected $fillable = [ 'first_name', 'last_name', - // 'email', - // 'phone', + 'email', + 'phone', 'signature', 'avatar', 'accepted_terms_version', @@ -323,4 +325,19 @@ class User extends Authenticatable implements MustVerifyEmail return null; } + + public function routeNotificationForSlack($notification) + { + //todo need to return the company channel here for hosted users + //else the env variable for selfhosted + return config('ninja.notification.slack'); + } + + public function preferredLocale() + { + $lang = Language::find($this->company()->settings->language_id); + + return $lang->locale; + } } + diff --git a/app/Notifications/NewAccountCreated.php b/app/Notifications/NewAccountCreated.php new file mode 100644 index 000000000000..7db995f8f5d7 --- /dev/null +++ b/app/Notifications/NewAccountCreated.php @@ -0,0 +1,84 @@ +user = $user; + $this->company = $company; + } + + /** + * Get the notification's delivery channels. + * + * @param mixed $notifiable + * @return array + */ + public function via($notifiable) + { + return ['slack']; + } + + /** + * Get the mail representation of the notification. + * + * @param mixed $notifiable + * @return \Illuminate\Notifications\Messages\MailMessage + */ + public function toMail($notifiable) + { + return (new MailMessage) + ->line('The introduction to the notification.') + ->action('Notification Action', url('/')) + ->line('Thank you for using our application!'); + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * @return array + */ + public function toArray($notifiable) + { + return [ + // + ]; + } + + public function toSlack($notifiable) + { + + $user_name = $this->user->first_name . " " . $this->user->last_name; + $email = $this->user->email; + $ip = $this->user->ip; + + return (new SlackMessage) + ->success() + ->to("#devv2") + ->from("System") + ->image('https://app.invoiceninja.com/favicon.png') + ->content("A new account has been created by {$user_name} - {$email} - from IP: {$ip}"); + } + +} diff --git a/composer.json b/composer.json index b5212f5d9103..4b6a128dc561 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ "intervention/image": "^2.4", "laracasts/presenter": "^0.2.1", "laravel/framework": "6.0.*", + "laravel/slack-notification-channel": "^2.0", "laravel/socialite": "^4.0", "laravel/tinker": "^1.0", "laravelcollective/html": "6.0.*", diff --git a/config/ninja.php b/config/ninja.php index ef1496e60672..1d5830a5c9ec 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -84,6 +84,9 @@ return [ //'frequencies' => 'App\Models\Frequency', //'fonts' => 'App\Models\Font', ], + 'notification' => [ + 'slack' => env('SLACK_WEBHOOK_URL',''), + ], 'payment_terms' => [ [ 'num_days' => 0, diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php index 132b28dad7e6..b2bfcb82cf51 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -230,6 +230,8 @@ class CreateUsersTable extends Migration $table->string('first_name')->nullable(); $table->string('last_name')->nullable(); $table->string('phone')->nullable(); + $table->string('ip')->nullable(); + $table->string('device_token')->nullable(); $table->string('email',100)->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('confirmation_code')->nullable(); diff --git a/resources/views/portal/default/dashboard/index.blade.php b/resources/views/portal/default/dashboard/index.blade.php index e5627ee650c1..fb3fb58520ba 100644 --- a/resources/views/portal/default/dashboard/index.blade.php +++ b/resources/views/portal/default/dashboard/index.blade.php @@ -3,6 +3,7 @@ @section('body')
+ @if($settings->enable_client_portal_dashboard == 'true')
@@ -40,6 +41,7 @@
+ @endif
diff --git a/resources/views/portal/default/layouts/master.blade.php b/resources/views/portal/default/layouts/master.blade.php index c17e093ee864..586c248836ff 100644 --- a/resources/views/portal/default/layouts/master.blade.php +++ b/resources/views/portal/default/layouts/master.blade.php @@ -56,4 +56,12 @@ @yield('body') @include('portal.default.footer') @yield('footer') - \ No newline at end of file + + + \ No newline at end of file diff --git a/resources/views/portal/default/recurring_invoices/request_cancellation.blade.php b/resources/views/portal/default/recurring_invoices/request_cancellation.blade.php new file mode 100644 index 000000000000..2768bf8e1725 --- /dev/null +++ b/resources/views/portal/default/recurring_invoices/request_cancellation.blade.php @@ -0,0 +1,40 @@ +@extends('portal.default.layouts.master') +@section('header') +@stop +@section('body') +
+
+
+
+
+
+ Request Cancellation +
+
+ + + + + + + +
{{ctrans('texts.start_date')}}{!! $invoice->start_date !!}
{{ctrans('texts.next_send_date')}}{!! $invoice->next_send_date !!}
{{ctrans('texts.frequency')}}{!! App\Models\RecurringInvoice::frequencyForKey($invoice->frequency_id) !!}
{{ctrans('texts.cycles_remaining')}}{!! $invoice->remaining_cycles !!}
{{ctrans('texts.amount')}}{!! $invoice->amount !!}
+ + + +
+
+
+
+
+
+ + +@endsection +@push('css') +@endpush +@push('scripts') +@endpush +@section('footer') +@endsection + diff --git a/resources/views/portal/default/recurring_invoices/show.blade.php b/resources/views/portal/default/recurring_invoices/show.blade.php index 816c67d2f108..b6175792ca73 100644 --- a/resources/views/portal/default/recurring_invoices/show.blade.php +++ b/resources/views/portal/default/recurring_invoices/show.blade.php @@ -28,7 +28,7 @@ @if($invoice->remaining_cycles >=1)
- +
@endif
@@ -38,6 +38,27 @@
+ @endsection @push('css') diff --git a/routes/client.php b/routes/client.php index dafa9a68e4bd..bfba4604e4cf 100644 --- a/routes/client.php +++ b/routes/client.php @@ -16,15 +16,16 @@ Route::group(['middleware' => ['auth:contact'], 'prefix' => 'client', 'as' => 'c Route::get('dashboard', 'ClientPortal\DashboardController@index')->name('dashboard'); // name = (dashboard. index / create / show / update / destroy / edit - Route::get('invoices', 'ClientPortal\InvoiceController@index')->name('invoices.index'); + Route::get('invoices', 'ClientPortal\InvoiceController@index')->name('invoices.index')->middleware('portal_enabled'); Route::post('invoices/payment', 'ClientPortal\InvoiceController@bulk')->name('invoices.bulk'); Route::get('invoices/{invoice}', 'ClientPortal\InvoiceController@show')->name('invoice.show'); 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', 'ClientPortal\RecurringInvoiceController@index')->name('recurring_invoices.index')->middleware('portal_enabled'); Route::get('recurring_invoices/{recurring_invoice}', 'ClientPortal\RecurringInvoiceController@show')->name('recurring_invoices.show'); + Route::get('recurring_invoices/{recurring_invoice}/request_cancellation', 'ClientPortal\RecurringInvoiceController@requestCancellation')->name('recurring_invoices.request_cancellation'); - Route::get('payments', 'ClientPortal\PaymentController@index')->name('payments.index'); + Route::get('payments', 'ClientPortal\PaymentController@index')->name('payments.index')->middleware('portal_enabled'); Route::get('payments/{payment}', 'ClientPortal\PaymentController@show')->name('payments.show'); Route::post('payments/process', 'ClientPortal\PaymentController@process')->name('payments.process'); Route::post('payments/process/response', 'ClientPortal\PaymentController@response')->name('payments.response'); diff --git a/tests/Feature/AccountTest.php b/tests/Feature/AccountTest.php index e2d83905a477..b74e7a288d86 100644 --- a/tests/Feature/AccountTest.php +++ b/tests/Feature/AccountTest.php @@ -72,7 +72,7 @@ class AccountTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $response->assertStatus(200); diff --git a/tests/Feature/ClientTest.php b/tests/Feature/ClientTest.php index 877f41c9d589..6955e95d6d6d 100644 --- a/tests/Feature/ClientTest.php +++ b/tests/Feature/ClientTest.php @@ -57,7 +57,7 @@ class ClientTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $response->assertStatus(200); @@ -98,7 +98,7 @@ class ClientTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $acc = $response->json(); diff --git a/tests/Feature/CompanySettingsTest.php b/tests/Feature/CompanySettingsTest.php index 30fedf1f37b8..0bb24658acbe 100644 --- a/tests/Feature/CompanySettingsTest.php +++ b/tests/Feature/CompanySettingsTest.php @@ -128,7 +128,7 @@ class CompanySettingsTest extends TestCase $settings->require_quote_signature = true; $settings->show_accept_quote_terms = false; $settings->show_accept_invoice_terms = "TRUE"; - $settings->show_tasks_in_portal = "FALSE"; + $settings->enable_client_portal_tasks = "FALSE"; $this->company->settings = $settings; diff --git a/tests/Feature/CompanyTest.php b/tests/Feature/CompanyTest.php index 022b4fa66363..83cbe171816b 100644 --- a/tests/Feature/CompanyTest.php +++ b/tests/Feature/CompanyTest.php @@ -58,7 +58,7 @@ class CompanyTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $response->assertStatus(200); @@ -80,7 +80,7 @@ class CompanyTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $token, - ])->post('/api/v1/companies/', + ])->post('/api/v1/companies?include=company', [ 'name' => 'A New Company', 'logo' => UploadedFile::fake()->image('avatar.jpg') diff --git a/tests/Feature/InvoiceTest.php b/tests/Feature/InvoiceTest.php index be82cc6a5e51..7f0a2627e020 100644 --- a/tests/Feature/InvoiceTest.php +++ b/tests/Feature/InvoiceTest.php @@ -61,7 +61,7 @@ class InvoiceTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $acc = $response->json(); diff --git a/tests/Feature/PaymentTest.php b/tests/Feature/PaymentTest.php index 9aba1fa49b10..2ab486d26994 100644 --- a/tests/Feature/PaymentTest.php +++ b/tests/Feature/PaymentTest.php @@ -58,7 +58,7 @@ class PaymentTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $acc = $response->json(); @@ -122,7 +122,7 @@ class PaymentTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $acc = $response->json(); diff --git a/tests/Feature/ProductTest.php b/tests/Feature/ProductTest.php index a49da7354226..8ecacba6131a 100644 --- a/tests/Feature/ProductTest.php +++ b/tests/Feature/ProductTest.php @@ -55,7 +55,7 @@ class ProductTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $response->assertStatus(200); diff --git a/tests/Feature/QuoteTest.php b/tests/Feature/QuoteTest.php index 6c200a9aa115..f3f95bd0f76d 100644 --- a/tests/Feature/QuoteTest.php +++ b/tests/Feature/QuoteTest.php @@ -57,7 +57,7 @@ class QuoteTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $acc = $response->json(); @@ -121,7 +121,7 @@ class QuoteTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $acc = $response->json(); diff --git a/tests/Feature/RecurringInvoiceTest.php b/tests/Feature/RecurringInvoiceTest.php index 0983e136af0f..1a7bf34db262 100644 --- a/tests/Feature/RecurringInvoiceTest.php +++ b/tests/Feature/RecurringInvoiceTest.php @@ -57,7 +57,7 @@ class RecurringInvoiceTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $acc = $response->json(); @@ -121,7 +121,7 @@ class RecurringInvoiceTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $acc = $response->json(); $account = Account::find($this->decodePrimaryKey($acc['data'][0]['account']['id'])); diff --git a/tests/Feature/RecurringQuoteTest.php b/tests/Feature/RecurringQuoteTest.php index 4bb354357eb2..11be88b4df6d 100644 --- a/tests/Feature/RecurringQuoteTest.php +++ b/tests/Feature/RecurringQuoteTest.php @@ -57,7 +57,7 @@ class RecurringQuoteTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $acc = $response->json(); @@ -121,7 +121,7 @@ class RecurringQuoteTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $acc = $response->json(); diff --git a/tests/Feature/UserTest.php b/tests/Feature/UserTest.php index 763131e2209d..0c63cf3a8996 100644 --- a/tests/Feature/UserTest.php +++ b/tests/Feature/UserTest.php @@ -56,7 +56,7 @@ class UserTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), - ])->post('/api/v1/signup', $data); + ])->post('/api/v1/signup?include=account', $data); $response->assertStatus(200);