mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for registration fields and ensure client contact email is unique per company
This commit is contained in:
parent
d79b374eda
commit
3e676d584b
@ -46,7 +46,7 @@ class ContactRegisterController extends Controller
|
|||||||
$t = app('translator');
|
$t = app('translator');
|
||||||
$t->replace(Ninja::transformTranslations($company->settings));
|
$t->replace(Ninja::transformTranslations($company->settings));
|
||||||
|
|
||||||
return render('auth.register', ['register_company' => $company, 'account' => $company->account]);
|
return render('auth.register', ['register_company' => $company, 'account' => $company->account, 'submitsForm' => false]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function register(RegisterRequest $request)
|
public function register(RegisterRequest $request)
|
||||||
|
@ -1,4 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
namespace App\Http\Requests\ClientPortal;
|
namespace App\Http\Requests\ClientPortal;
|
||||||
|
|
||||||
@ -7,6 +16,7 @@ use App\Models\Account;
|
|||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class RegisterRequest extends FormRequest
|
class RegisterRequest extends FormRequest
|
||||||
{
|
{
|
||||||
@ -31,13 +41,13 @@ class RegisterRequest extends FormRequest
|
|||||||
|
|
||||||
foreach ($this->company()->client_registration_fields as $field) {
|
foreach ($this->company()->client_registration_fields as $field) {
|
||||||
if ($field['required']) {
|
if ($field['required']) {
|
||||||
$rules[$field['key']] = ['required'];
|
$rules[$field['key']] = ['bail','required'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($rules as $field => $properties) {
|
foreach ($rules as $field => $properties) {
|
||||||
if ($field === 'email') {
|
if ($field === 'email') {
|
||||||
$rules[$field] = array_merge($rules[$field], ['email:rfc,dns', 'max:255']);
|
$rules[$field] = array_merge($rules[$field], ['email:rfc,dns', 'max:255', Rule::unique('client_contacts')->where('company_id', $this->company()->id)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($field === 'current_password') {
|
if ($field === 'current_password') {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
@section('meta_title', ctrans('texts.register'))
|
@section('meta_title', ctrans('texts.register'))
|
||||||
|
|
||||||
@section('body')
|
@section('body')
|
||||||
|
|
||||||
<div class="grid lg:grid-cols-12 py-8">
|
<div class="grid lg:grid-cols-12 py-8">
|
||||||
<div class="col-span-12 lg:col-span-8 lg:col-start-3 xl:col-span-6 xl:col-start-4 px-6">
|
<div class="col-span-12 lg:col-span-8 lg:col-start-3 xl:col-span-6 xl:col-start-4 px-6">
|
||||||
<div class="flex justify-center">
|
<div class="flex justify-center">
|
||||||
@ -10,7 +11,7 @@
|
|||||||
<h1 class="text-center text-3xl mt-8">{{ ctrans('texts.register') }}</h1>
|
<h1 class="text-center text-3xl mt-8">{{ ctrans('texts.register') }}</h1>
|
||||||
<p class="block text-center text-gray-600">{{ ctrans('texts.register_label') }}</p>
|
<p class="block text-center text-gray-600">{{ ctrans('texts.register_label') }}</p>
|
||||||
|
|
||||||
<form action="{{ route('client.register', request()->route('company_key')) }}" method="POST" x-data="{ more: false }">
|
<form action="{{ route('client.register', request()->route('company_key')) }}" method="POST" x-data="{more: false, busy: false, isSubmitted: false}" x-on:submit="isSubmitted = true">
|
||||||
@if($register_company)
|
@if($register_company)
|
||||||
<input type="hidden" name="company_key" value="{{ $register_company->company_key }}">
|
<input type="hidden" name="company_key" value="{{ $register_company->company_key }}">
|
||||||
@endif
|
@endif
|
||||||
@ -40,15 +41,15 @@
|
|||||||
class="input w-full"
|
class="input w-full"
|
||||||
type="email"
|
type="email"
|
||||||
name="{{ $field['key'] }}"
|
name="{{ $field['key'] }}"
|
||||||
value=""
|
value="{{ old($field['key']) }}"
|
||||||
{{ $field['required'] ? 'required' : '' }} />
|
/>
|
||||||
@elseif($field['key'] === 'password')
|
@elseif($field['key'] === 'password')
|
||||||
<input
|
<input
|
||||||
id="{{ $field['key'] }}"
|
id="{{ $field['key'] }}"
|
||||||
class="input w-full"
|
class="input w-full"
|
||||||
type="password"
|
type="password"
|
||||||
name="{{ $field['key'] }}"
|
name="{{ $field['key'] }}"
|
||||||
{{ $field['required'] ? 'required' : '' }} />
|
/>
|
||||||
@elseif($field['key'] === 'country_id')
|
@elseif($field['key'] === 'country_id')
|
||||||
<select
|
<select
|
||||||
id="shipping_country"
|
id="shipping_country"
|
||||||
@ -69,7 +70,7 @@
|
|||||||
class="input w-full"
|
class="input w-full"
|
||||||
name="{{ $field['key'] }}"
|
name="{{ $field['key'] }}"
|
||||||
value="{{ old($field['key']) }}"
|
value="{{ old($field['key']) }}"
|
||||||
{{ $field['required'] ? 'required' : '' }} />
|
/>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@error($field['key'])
|
@error($field['key'])
|
||||||
@ -98,7 +99,7 @@
|
|||||||
type="password"
|
type="password"
|
||||||
class="input w-full"
|
class="input w-full"
|
||||||
name="password_confirmation"
|
name="password_confirmation"
|
||||||
{{ $field['required'] ? 'required' : '' }} />
|
/>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
@ -124,7 +125,8 @@
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<button class="button button-primary bg-blue-600">{{ ctrans('texts.register') }}</button>
|
<button class="button button-primary bg-blue-600" :disabled={{ $submitsForm == 'true' ? 'isSubmitted' : 'busy'}} x-on:click="busy = true">{{ ctrans('texts.register')}}</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user