1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 05:32:39 +01:00

Merge pull request #5930 from turbo124/v5-develop

Fixes for contact registration
This commit is contained in:
David Bomba 2021-06-05 20:12:49 +10:00 committed by GitHub
commit dc8603b4ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 5 deletions

View File

@ -19,10 +19,36 @@ class ContactRegister
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
// Resolving based on subdomain. Used in version 5 hosted platform.
if ($request->subdomain) {
$company = Company::where('subdomain', $request->subdomain)->firstOrFail();
if (strpos($request->getHost(), 'invoicing.co') !== false)
{
$subdomain = explode('.', $request->getHost())[0];
$query = [
'subdomain' => $subdomain,
'portal_mode' => 'subdomain',
];
$company = Company::where($query)->first();
if($company)
{
abort_unless($company->getSetting('enable_client_registration'), 404);
$request->merge(['key' => $company->company_key]);
return $next($request);
}
}
$query = [
'portal_domain' => $request->getSchemeAndHttpHost(),
'portal_mode' => 'domain',
];
if($company = Company::where($query)->first())
{
abort_unless($company->getSetting('enable_client_registration'), 404); abort_unless($company->getSetting('enable_client_registration'), 404);
$request->merge(['key' => $company->company_key]); $request->merge(['key' => $company->company_key]);
@ -30,6 +56,7 @@ class ContactRegister
return $next($request); return $next($request);
} }
// For self-hosted platforms with multiple companies, resolving is done using company key // For self-hosted platforms with multiple companies, resolving is done using company key
// if it doesn't resolve using a domain. // if it doesn't resolve using a domain.
if ($request->route()->parameter('company_key') && Ninja::isSelfHost()) { if ($request->route()->parameter('company_key') && Ninja::isSelfHost()) {

View File

@ -1,4 +1,4 @@
<?php .register<?php
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
@ -8,7 +8,7 @@ Route::get('client/login', 'Auth\ContactLoginController@showLoginForm')->name('c
Route::post('client/login', 'Auth\ContactLoginController@login')->name('client.login.submit'); Route::post('client/login', 'Auth\ContactLoginController@login')->name('client.login.submit');
Route::get('client/register/{company_key?}', 'Auth\ContactRegisterController@showRegisterForm')->name('client.register')->middleware(['domain_db', 'contact_account','locale']); Route::get('client/register/{company_key?}', 'Auth\ContactRegisterController@showRegisterForm')->name('client.register')->middleware(['domain_db', 'contact_account','locale']);
Route::post('client/register/{company_key?}', 'Auth\ContactRegisterController@register'); Route::post('client/register/{company_key?}', 'Auth\ContactRegisterController@register')->middleware(['domain_db', 'contact_account','locale']);
Route::get('client/password/reset', 'Auth\ContactForgotPasswordController@showLinkRequestForm')->name('client.password.request')->middleware(['domain_db', 'contact_account','locale']); Route::get('client/password/reset', 'Auth\ContactForgotPasswordController@showLinkRequestForm')->name('client.password.request')->middleware(['domain_db', 'contact_account','locale']);
Route::post('client/password/email', 'Auth\ContactForgotPasswordController@sendResetLinkEmail')->name('client.password.email')->middleware('locale'); Route::post('client/password/email', 'Auth\ContactForgotPasswordController@sendResetLinkEmail')->name('client.password.email')->middleware('locale');