mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for contact registration
This commit is contained in:
parent
b654639ad3
commit
4c00403d8c
@ -33,7 +33,8 @@ class ContactRegister
|
||||
|
||||
if($company)
|
||||
{
|
||||
abort_unless($company->client_can_register, 404);
|
||||
if(! $company->client_can_register)
|
||||
abort(400, 'Registration disabled');
|
||||
|
||||
$request->merge(['key' => $company->company_key]);
|
||||
|
||||
@ -49,7 +50,9 @@ class ContactRegister
|
||||
|
||||
if($company = Company::where($query)->first())
|
||||
{
|
||||
abort_unless($company->client_can_register, 404);
|
||||
|
||||
if(! $company->client_can_register)
|
||||
abort(400, 'Registration disabled');
|
||||
|
||||
$request->merge(['key' => $company->company_key]);
|
||||
|
||||
@ -62,7 +65,10 @@ class ContactRegister
|
||||
if ($request->route()->parameter('company_key') && Ninja::isSelfHost()) {
|
||||
$company = Company::where('company_key', $request->company_key)->firstOrFail();
|
||||
|
||||
abort_unless($company->client_can_register, 404);
|
||||
if(! (bool)$company->client_can_register);
|
||||
abort(400, 'Registration disabled');
|
||||
|
||||
$request->merge(['key' => $company->company_key]);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
@ -72,7 +78,8 @@ class ContactRegister
|
||||
if (!$request->route()->parameter('company_key') && Ninja::isSelfHost()) {
|
||||
$company = Account::first()->default_company;
|
||||
|
||||
abort_unless($company->client_can_register, 404);
|
||||
if(! $company->client_can_register)
|
||||
abort(400, 'Registration disabled');
|
||||
|
||||
$request->merge(['key' => $company->company_key]);
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Requests\ClientPortal;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Account;
|
||||
use App\Models\Company;
|
||||
use App\Utils\Ninja;
|
||||
@ -36,10 +37,11 @@ class RegisterRequest extends FormRequest
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
if ($this->subdomain) {
|
||||
return Company::where('subdomain', $this->subdomain)->firstOrFail();
|
||||
}
|
||||
{
|
||||
|
||||
//this should be all we need, the rest SHOULD be redundant because of our Middleware
|
||||
if ($this->key)
|
||||
return Company::where('company_key', $this->key)->first();
|
||||
|
||||
if ($this->company_key) {
|
||||
return Company::where('company_key', $this->company_key)->firstOrFail();
|
||||
@ -48,11 +50,34 @@ class RegisterRequest extends FormRequest
|
||||
if (!$this->route()->parameter('company_key') && Ninja::isSelfHost()) {
|
||||
$company = Account::first()->default_company;
|
||||
|
||||
abort_unless($company->client_can_register, 404);
|
||||
if(!$company->client_can_register)
|
||||
abort(403, "This page is restricted");
|
||||
|
||||
return $company;
|
||||
}
|
||||
|
||||
abort(404, 'Register request not found.');
|
||||
if (Ninja::isHosted()) {
|
||||
|
||||
$subdomain = explode('.', $this->getHost())[0];
|
||||
|
||||
$query = [
|
||||
'subdomain' => $subdomain,
|
||||
'portal_mode' => 'subdomain',
|
||||
];
|
||||
|
||||
if($company = MultiDB::findAndSetDbByDomain($query))
|
||||
return $company;
|
||||
|
||||
$query = [
|
||||
'portal_domain' => $this->getSchemeAndHttpHost(),
|
||||
'portal_mode' => 'domain',
|
||||
];
|
||||
|
||||
if($company = MultiDB::findAndSetDbByDomain($query))
|
||||
return $company;
|
||||
|
||||
}
|
||||
|
||||
abort(400, 'Register request not found.');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user