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->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)
|
||||
|
@ -1,4 +1,13 @@
|
||||
<?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;
|
||||
|
||||
@ -7,6 +16,7 @@ use App\Models\Account;
|
||||
use App\Models\Company;
|
||||
use App\Utils\Ninja;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class RegisterRequest extends FormRequest
|
||||
{
|
||||
@ -31,13 +41,13 @@ class RegisterRequest extends FormRequest
|
||||
|
||||
foreach ($this->company()->client_registration_fields as $field) {
|
||||
if ($field['required']) {
|
||||
$rules[$field['key']] = ['required'];
|
||||
$rules[$field['key']] = ['bail','required'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($rules as $field => $properties) {
|
||||
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') {
|
||||
|
@ -2,6 +2,7 @@
|
||||
@section('meta_title', ctrans('texts.register'))
|
||||
|
||||
@section('body')
|
||||
|
||||
<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="flex justify-center">
|
||||
@ -10,7 +11,7 @@
|
||||
<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>
|
||||
|
||||
<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)
|
||||
<input type="hidden" name="company_key" value="{{ $register_company->company_key }}">
|
||||
@endif
|
||||
@ -40,15 +41,15 @@
|
||||
class="input w-full"
|
||||
type="email"
|
||||
name="{{ $field['key'] }}"
|
||||
value=""
|
||||
{{ $field['required'] ? 'required' : '' }} />
|
||||
value="{{ old($field['key']) }}"
|
||||
/>
|
||||
@elseif($field['key'] === 'password')
|
||||
<input
|
||||
id="{{ $field['key'] }}"
|
||||
class="input w-full"
|
||||
type="password"
|
||||
name="{{ $field['key'] }}"
|
||||
{{ $field['required'] ? 'required' : '' }} />
|
||||
/>
|
||||
@elseif($field['key'] === 'country_id')
|
||||
<select
|
||||
id="shipping_country"
|
||||
@ -69,7 +70,7 @@
|
||||
class="input w-full"
|
||||
name="{{ $field['key'] }}"
|
||||
value="{{ old($field['key']) }}"
|
||||
{{ $field['required'] ? 'required' : '' }} />
|
||||
/>
|
||||
@endif
|
||||
|
||||
@error($field['key'])
|
||||
@ -98,7 +99,7 @@
|
||||
type="password"
|
||||
class="input w-full"
|
||||
name="password_confirmation"
|
||||
{{ $field['required'] ? 'required' : '' }} />
|
||||
/>
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
@ -124,7 +125,8 @@
|
||||
</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>
|
||||
</form>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user