mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Merge pull request #4934 from beganovich/v5-1702-client-registration-fallback
(v5) Fallback to default company for registration
This commit is contained in:
commit
6bafc35936
@ -18,11 +18,13 @@ class ContactRegisterController extends Controller
|
||||
$this->middleware(['guest', 'contact.register']);
|
||||
}
|
||||
|
||||
public function showRegisterForm(string $company_key)
|
||||
public function showRegisterForm(string $company_key = '')
|
||||
{
|
||||
$company = Company::where('company_key', $company_key)->firstOrFail();
|
||||
$key = request()->has('key') ? request('key') : $company_key;
|
||||
|
||||
return render('auth.register', compact(['company']));
|
||||
$company = Company::where('company_key', $key)->firstOrFail();
|
||||
|
||||
return render('auth.register', ['company' => $company]);
|
||||
}
|
||||
|
||||
public function register(RegisterRequest $request)
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Models\Company;
|
||||
use App\Utils\Ninja;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@ -11,35 +13,45 @@ class ContactRegister
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
/*
|
||||
* Notes:
|
||||
*
|
||||
* 1. If request supports subdomain (for hosted) check domain and continue request.
|
||||
* 2. If request doesn't support subdomain and doesn' have company_key, abort
|
||||
* 3. firstOrFail() will abort with 404 if company with company_key wasn't found.
|
||||
* 4. Abort if setting isn't enabled.
|
||||
*/
|
||||
|
||||
// Resolving based on subdomain. Used in version 5 hosted platform.
|
||||
if ($request->subdomain) {
|
||||
$company = Company::where('subdomain', $request->subdomain)->firstOrFail();
|
||||
|
||||
abort_unless($company->getSetting('enable_client_registration'), 404);
|
||||
|
||||
$request->merge(['key' => $company->company_key]);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
abort_unless($request->company_key, 404);
|
||||
// For self-hosted platforms with multiple companies, resolving is done using company key
|
||||
// if it doesn't resolve using a domain.
|
||||
if ($request->route()->parameter('company_key') && Ninja::isSelfHost()) {
|
||||
$company = Company::where('company_key', $request->company_key)->firstOrFail();
|
||||
|
||||
$company = Company::where('company_key', $request->company_key)->firstOrFail();
|
||||
abort_unless($company->client_can_register, 404);
|
||||
|
||||
abort_unless($company->client_can_register, 404);
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
// As a fallback for self-hosted, it will use default company in the system
|
||||
// if key isn't provided in the url.
|
||||
if (!$request->route()->parameter('company_key') && Ninja::isSelfHost()) {
|
||||
$company = Account::first()->default_company;
|
||||
|
||||
abort_unless($company->client_can_register, 404);
|
||||
|
||||
$request->merge(['key' => $company->company_key]);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
return abort(404);
|
||||
}
|
||||
}
|
||||
|
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=1ee684e58f9f6eb754d5",
|
||||
"/css/app.css": "/css/app.css?id=c6df2680d8efda824069",
|
||||
"/css/app.css": "/css/app.css?id=7e5d2c66e34a0d6fd333",
|
||||
"/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/payment_methods/authorize-authorize-card.js": "/js/clients/payment_methods/authorize-authorize-card.js?id=206d7de4ac97612980ff",
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
<div class="col-span-6 sm:col-span-3">
|
||||
<label for="website" class="input-label">{{ ctrans('texts.website') }}</label>
|
||||
<input id="website" class="input w-full" name="last_name" />
|
||||
<input id="website" class="input w-full" name="website" />
|
||||
@error('website')
|
||||
<div class="validation validation-fail">
|
||||
{{ $message }}
|
||||
@ -29,4 +29,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
@section('body')
|
||||
<div class="grid lg:grid-cols-12 py-8">
|
||||
<div class="col-span-4 col-start-5">
|
||||
<div class="lg:col-span-4 lg:col-start-5 px-6">
|
||||
<div class="flex justify-center">
|
||||
<img class="h-32 w-auto" src="{{ $company->present()->logo() }}" alt="{{ ctrans('texts.logo') }}">
|
||||
</div>
|
||||
@ -21,7 +21,7 @@
|
||||
@include('portal.ninja2020.auth.includes.register.personal_address')
|
||||
@include('portal.ninja2020.auth.includes.register.shipping_address')
|
||||
</div>
|
||||
|
||||
|
||||
<div class="flex justify-between items-center mt-8">
|
||||
<span class="inline-flex items-center" x-data="{ terms_of_service: false, privacy_policy: false }">
|
||||
@if(!empty($company->settings->client_portal_terms) || !empty($company->settings->client_portal_privacy_policy))
|
||||
@ -36,9 +36,9 @@
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<button class="button button-primary bg-blue-600">{{ ctrans('texts.save') }}</button>
|
||||
<button class="button button-primary bg-blue-600">{{ ctrans('texts.register') }}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@endsection
|
||||
|
Loading…
Reference in New Issue
Block a user