mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Fixes for hosted onboarding
This commit is contained in:
parent
9f41d73c27
commit
296cb0511b
50
app/Http/Controllers/ClientPortal/NinjaPlanController.php
Normal file
50
app/Http/Controllers/ClientPortal/NinjaPlanController.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?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\ClientPortal;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\ClientPortal\Uploads\StoreUploadRequest;
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\ClientContact;
|
||||||
|
use App\Utils\Ninja;
|
||||||
|
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class NinjaPlanController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function index(string $contact_key)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Ninja::isHosted() && MultiDB::findAndSetDbByContactKey(request()->segment(3)) && $client_contact = ClientContact::where('contact_key', request()->segment(3))->first())
|
||||||
|
{
|
||||||
|
// auth()->guard('contact')->login($client_contact, true);
|
||||||
|
Auth::guard('contact')->login($client_contact);
|
||||||
|
|
||||||
|
/* Harvest user account*/
|
||||||
|
$account = $client_contact->company->account;
|
||||||
|
|
||||||
|
/* Current paid users get pushed straight to subscription overview page*/
|
||||||
|
if($account->isPaid())
|
||||||
|
return redirect('/client/subscriptions');
|
||||||
|
|
||||||
|
/* Users that are not paid get pushed to a custom purchase page */
|
||||||
|
return $this->render('subscriptions.ninja_plan', ['settings' => $client_contact->company->settings]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('client.catchall');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -58,13 +58,20 @@ class ContactKeyLogin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($request->segment(3) && config('ninja.db.multi_db_enabled')) {
|
elseif ($request->segment(3) && config('ninja.db.multi_db_enabled')) {
|
||||||
if (MultiDB::findAndSetDbByContactKey($request->segment(3))) {
|
|
||||||
|
|
||||||
|
if (MultiDB::findAndSetDbByContactKey($request->segment(3))) {
|
||||||
|
|
||||||
if($client_contact = ClientContact::where('contact_key', $request->segment(3))->first()){
|
if($client_contact = ClientContact::where('contact_key', $request->segment(3))->first()){
|
||||||
|
|
||||||
if(empty($client_contact->email))
|
if(empty($client_contact->email))
|
||||||
$client_contact->email = Str::random(6) . "@example.com"; $client_contact->save();
|
$client_contact->email = Str::random(6) . "@example.com"; $client_contact->save();
|
||||||
|
|
||||||
Auth::guard('contact')->login($client_contact, true);
|
auth()->guard('contact')->login($client_contact, true);
|
||||||
|
|
||||||
|
if ($request->query('next')) {
|
||||||
|
return redirect()->to($request->query('next'));
|
||||||
|
}
|
||||||
|
|
||||||
return redirect()->to('client/dashboard');
|
return redirect()->to('client/dashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,12 +48,13 @@ class PortalComposer
|
|||||||
*/
|
*/
|
||||||
public function compose(View $view) :void
|
public function compose(View $view) :void
|
||||||
{
|
{
|
||||||
|
|
||||||
$view->with($this->portalData());
|
$view->with($this->portalData());
|
||||||
|
|
||||||
if (auth()->user()) {
|
if (auth('contact')->user()) {
|
||||||
App::forgetInstance('translator');
|
App::forgetInstance('translator');
|
||||||
$t = app('translator');
|
$t = app('translator');
|
||||||
$t->replace(Ninja::transformTranslations(auth()->user()->client->getMergedSettings()));
|
$t->replace(Ninja::transformTranslations(auth('contact')->user()->client->getMergedSettings()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,18 +63,18 @@ class PortalComposer
|
|||||||
*/
|
*/
|
||||||
private function portalData() :array
|
private function portalData() :array
|
||||||
{
|
{
|
||||||
if (! auth()->user()) {
|
if (! auth('contact')->user()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->settings = auth()->user()->client->getMergedSettings();
|
$this->settings = auth('contact')->user()->client->getMergedSettings();
|
||||||
|
|
||||||
$data['sidebar'] = $this->sidebarMenu();
|
$data['sidebar'] = $this->sidebarMenu();
|
||||||
$data['header'] = [];
|
$data['header'] = [];
|
||||||
$data['footer'] = [];
|
$data['footer'] = [];
|
||||||
$data['countries'] = TranslationHelper::getCountries();
|
$data['countries'] = TranslationHelper::getCountries();
|
||||||
$data['company'] = auth()->user()->company;
|
$data['company'] = auth('contact')->user()->company;
|
||||||
$data['client'] = auth()->user()->client;
|
$data['client'] = auth('contact')->user()->client;
|
||||||
$data['settings'] = $this->settings;
|
$data['settings'] = $this->settings;
|
||||||
$data['currencies'] = TranslationHelper::getCurrencies();
|
$data['currencies'] = TranslationHelper::getCurrencies();
|
||||||
$data['contact'] = auth('contact')->user();
|
$data['contact'] = auth('contact')->user();
|
||||||
@ -114,7 +115,7 @@ class PortalComposer
|
|||||||
$data[] = ['title' => ctrans('texts.documents'), 'url' => 'client.documents.index', 'icon' => 'download'];
|
$data[] = ['title' => ctrans('texts.documents'), 'url' => 'client.documents.index', 'icon' => 'download'];
|
||||||
$data[] = ['title' => ctrans('texts.subscriptions'), 'url' => 'client.subscriptions.index', 'icon' => 'calendar'];
|
$data[] = ['title' => ctrans('texts.subscriptions'), 'url' => 'client.subscriptions.index', 'icon' => 'calendar'];
|
||||||
|
|
||||||
if (auth()->user('contact')->client->getSetting('enable_client_portal_tasks')) {
|
if (auth('contact')->user()->client->getSetting('enable_client_portal_tasks')) {
|
||||||
$data[] = ['title' => ctrans('texts.tasks'), 'url' => 'client.tasks.index', 'icon' => 'clock'];
|
$data[] = ['title' => ctrans('texts.tasks'), 'url' => 'client.tasks.index', 'icon' => 'clock'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ class Payment extends BaseModel
|
|||||||
else
|
else
|
||||||
$domain = config('ninja.app_url');
|
$domain = config('ninja.app_url');
|
||||||
|
|
||||||
return $domain.'/client/payment/'. $this->client->contacts()->first()->contact_key .'/' .$this->hashed_id;
|
return $domain.'/client/payment/'. $this->client->contacts()->first()->contact_key .'/'. $this->hashed_id."?next=/client/payments/".$this->hashed_id;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
2
public/css/app.css
vendored
2
public/css/app.css
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"/js/app.js": "/js/app.js?id=696e8203d5e8e7cf5ff5",
|
"/js/app.js": "/js/app.js?id=696e8203d5e8e7cf5ff5",
|
||||||
"/css/app.css": "/css/app.css?id=27d1431e24a51260d3f1",
|
"/css/app.css": "/css/app.css?id=f0b3774b6c3be0a294a7",
|
||||||
"/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=a09bb529b8e1826f13b4",
|
"/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=a09bb529b8e1826f13b4",
|
||||||
"/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=8ce8955ba775ea5f47d1",
|
"/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=8ce8955ba775ea5f47d1",
|
||||||
"/js/clients/linkify-urls.js": "/js/clients/linkify-urls.js?id=0dc8c34010d09195d2f7",
|
"/js/clients/linkify-urls.js": "/js/clients/linkify-urls.js?id=0dc8c34010d09195d2f7",
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@if(auth()->user()->user && !auth()->user()->user->account->isPaid())
|
@if(auth('contact')->user()->user && !auth('contact')->user()->user->account->isPaid())
|
||||||
<a href="https://invoiceninja.com" target="_blank">
|
<a href="https://invoiceninja.com" target="_blank">
|
||||||
<img class="h-8" src="{{ asset('images/invoiceninja-black-logo-2.png') }}" alt="Invoice Ninja Logo">
|
<img class="h-8" src="{{ asset('images/invoiceninja-black-logo-2.png') }}" alt="Invoice Ninja Logo">
|
||||||
</a>
|
</a>
|
||||||
|
@ -37,8 +37,8 @@
|
|||||||
<div>
|
<div>
|
||||||
<button data-ref="client-profile-dropdown" @click="open = !open"
|
<button data-ref="client-profile-dropdown" @click="open = !open"
|
||||||
class="max-w-xs flex items-center text-sm rounded-full focus:outline-none focus:shadow-outline">
|
class="max-w-xs flex items-center text-sm rounded-full focus:outline-none focus:shadow-outline">
|
||||||
<img class="h-8 w-8 rounded-full" src="{{ auth()->user()->avatar() }}" alt=""/>
|
<img class="h-8 w-8 rounded-full" src="{{ auth('contact')->user()->avatar() }}" alt=""/>
|
||||||
<span class="ml-2">{{ auth()->user()->present()->name() }}</span>
|
<span class="ml-2">{{ auth('contact')->user()->present()->name() }}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div x-show="open" style="display:none;" x-transition:enter="transition ease-out duration-100"
|
<div x-show="open" style="display:none;" x-transition:enter="transition ease-out duration-100"
|
||||||
@ -50,7 +50,7 @@
|
|||||||
class="origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg">
|
class="origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg">
|
||||||
<div class="py-1 rounded-md bg-white shadow-xs">
|
<div class="py-1 rounded-md bg-white shadow-xs">
|
||||||
<a data-ref="client-profile-dropdown-settings"
|
<a data-ref="client-profile-dropdown-settings"
|
||||||
href="{{ route('client.profile.edit', ['client_contact' => auth()->user()->hashed_id]) }}"
|
href="{{ route('client.profile.edit', ['client_contact' => auth('contact')->user()->hashed_id]) }}"
|
||||||
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 transition ease-in-out duration-150">
|
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 transition ease-in-out duration-150">
|
||||||
{{ ctrans('texts.profile') }}
|
{{ ctrans('texts.profile') }}
|
||||||
</a>
|
</a>
|
||||||
|
@ -26,7 +26,7 @@ Route::get('client/magic_link/{magic_link}', 'ClientPortal\ContactHashLoginContr
|
|||||||
Route::get('documents/{document_hash}', 'ClientPortal\DocumentController@publicDownload')->name('documents.public_download')->middleware(['document_db']);
|
Route::get('documents/{document_hash}', 'ClientPortal\DocumentController@publicDownload')->name('documents.public_download')->middleware(['document_db']);
|
||||||
Route::get('error', 'ClientPortal\ContactHashLoginController@errorPage')->name('client.error');
|
Route::get('error', 'ClientPortal\ContactHashLoginController@errorPage')->name('client.error');
|
||||||
Route::get('client/payment/{contact_key}/{payment_id}', 'ClientPortal\InvitationController@paymentRouter')->middleware(['domain_db','contact_key_login']);
|
Route::get('client/payment/{contact_key}/{payment_id}', 'ClientPortal\InvitationController@paymentRouter')->middleware(['domain_db','contact_key_login']);
|
||||||
|
Route::get('client/ninja/{contact_key}', 'ClientPortal\NinjaPlanController@index')->name('client.ninja_contact_login')->middleware(['domain_db']);
|
||||||
|
|
||||||
Route::group(['middleware' => ['auth:contact', 'locale', 'check_client_existence','domain_db'], 'prefix' => 'client', 'as' => 'client.'], function () {
|
Route::group(['middleware' => ['auth:contact', 'locale', 'check_client_existence','domain_db'], 'prefix' => 'client', 'as' => 'client.'], function () {
|
||||||
Route::get('dashboard', 'ClientPortal\DashboardController@index')->name('dashboard'); // name = (dashboard. index / create / show / update / destroy / edit
|
Route::get('dashboard', 'ClientPortal\DashboardController@index')->name('dashboard'); // name = (dashboard. index / create / show / update / destroy / edit
|
||||||
|
Loading…
Reference in New Issue
Block a user