Enabled form validation
This commit is contained in:
parent
f01f88b3bd
commit
eafae02c7b
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Classes\LDAP\Schema;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@ -271,6 +272,7 @@ final class AttributeType extends Base {
|
||||
case 'type': return $this->type;
|
||||
case 'usage': return $this->usage;
|
||||
case 'used_in_object_classes': return $this->used_in_object_classes;
|
||||
case 'validation': return Arr::get(config('ldap.validation'),$this->name_lc);
|
||||
|
||||
default: return parent::__get($key);
|
||||
}
|
||||
|
@ -112,10 +112,10 @@ class HomeController extends Controller
|
||||
];
|
||||
});
|
||||
|
||||
if (Session::has('dn'))
|
||||
if (old('dn'))
|
||||
return view('dn')
|
||||
->with('bases',$bases)
|
||||
->with('o',config('server')->fetch($dn=Crypt::decryptString(Session::pull('dn'))))
|
||||
->with('o',config('server')->fetch($dn=Crypt::decryptString(old('dn'))))
|
||||
->with('dn',$dn);
|
||||
else
|
||||
return view('home')
|
||||
|
@ -23,9 +23,12 @@ class EntryRequest extends FormRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'dn'=>'string|min:3',
|
||||
'objectclass'=>'array|min:1',
|
||||
];
|
||||
return config('server')
|
||||
->schema('attributetypes')
|
||||
->intersectByKeys($this->request)
|
||||
->transform(function($item) { return $item->validation; })
|
||||
->filter()
|
||||
->flatMap(function($item) { return $item; })
|
||||
->toArray();
|
||||
}
|
||||
}
|
@ -111,4 +111,19 @@ return [
|
||||
|
|
||||
*/
|
||||
'datetime_format' => 'Y-m-d H:i:s',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Validation
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Default validation used for data input.
|
||||
|
|
||||
*/
|
||||
'validation' => [
|
||||
'objectclass' => ['objectclass'=>['array','min:1']],
|
||||
'gidnumber' => ['gidnumber'=>['sometimes','array','max:1'],'gidnumber.*'=>['integer','max:65535']],
|
||||
'mail' => ['mail'=>['sometimes','array','min:1'],'mail.*'=>['email']],
|
||||
'uidnumber' => ['uidnumber'=>['sometimes','array','max:1'],'uidnumber.*'=>['integer','max:65535']],
|
||||
],
|
||||
];
|
||||
|
6
public/css/fixes.css
vendored
6
public/css/fixes.css
vendored
@ -229,7 +229,11 @@ p {
|
||||
}
|
||||
|
||||
/** Make our placeholder text on forms lighter **/
|
||||
|
||||
.form-control::placeholder {
|
||||
color: #a0aec0;
|
||||
}
|
||||
|
||||
/** Force our validation color to have a higher priority than any specified border **/
|
||||
.was-validated .form-control:invalid, .form-control.is-invalid {
|
||||
border-color: #d92550 !important;
|
||||
}
|
@ -4,7 +4,14 @@
|
||||
<div id="{{ $o->name_lc }}">
|
||||
@foreach (old($o->name_lc,$o->values) as $value)
|
||||
@if ($edit && ! $o->is_rdn)
|
||||
<input class="form-control mb-1 @if($x=($o->values->search($value) === FALSE)) border-focus @endif" type="text" name="{{ $o->name_lc }}[]" value="{{ $value }}" placeholder="{{ Arr::get($o->values,$loop->index) ?: '['.__('NEW').']' }}" readonly="true">
|
||||
<div class="input-group has-validation">
|
||||
<input type="text" class="form-control @if($e=$errors->get($o->name_lc.'.'.$loop->index))is-invalid @endif mb-1 @if($o->values->search($value) === FALSE) border-focus @endif" name="{{ $o->name_lc }}[]" value="{{ $value }}" placeholder="{{ ! is_null($x=Arr::get($o->values,$loop->index)) ? $x : '['.__('NEW').']' }}" readonly="true">
|
||||
<div class="invalid-feedback pb-2">
|
||||
@if($e)
|
||||
{{ join('|',$e) }}
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
{{ $value }}<br>
|
||||
@endif
|
||||
|
@ -1,5 +1,9 @@
|
||||
<!-- $o=Binary\JpegPhoto::class -->
|
||||
<table class="table table-borderless p-0 m-0">
|
||||
@if($edit)
|
||||
<div class="input-group has-validation @if($e=$errors->get($o->name_lc))is-invalid @endif">
|
||||
@endif
|
||||
|
||||
<table class="table table-borderless p-0 m-0">
|
||||
<tr>
|
||||
@foreach ($o->values as $value)
|
||||
@switch ($x=$f->buffer($value,FILEINFO_MIME_TYPE))
|
||||
@ -16,4 +20,14 @@
|
||||
@endswitch
|
||||
@endforeach
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
|
||||
@if($edit)
|
||||
<div class="invalid-feedback pb-2">
|
||||
@if($e)
|
||||
{{ join('|',$e) }}
|
||||
@endif
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endif
|
@ -4,7 +4,14 @@
|
||||
<div id="{{ $o->name_lc }}">
|
||||
@foreach (old($o->name_lc,$o->values) as $value)
|
||||
@if ($edit && ($value === NULL || (! $o->isStructural($value))))
|
||||
<input class="form-control mb-1 @if($o->values->search($value) === FALSE) border-focus @endif" type="text" name="{{ $o->name_lc }}[]" value="{{ $value }}" placeholder="{{ Arr::get($o->values,$loop->index) ?: '['.__('NEW').']' }}" readonly="true">
|
||||
<div class="input-group has-validation">
|
||||
<input type="text" class="form-control @if($e=$errors->get($o->name_lc.'.'.$loop->index))is-invalid @endif mb-1 @if($o->values->search($value) === FALSE) border-focus @endif" name="{{ $o->name_lc }}[]" value="{{ $value }}" placeholder="{{ ! is_null($x=Arr::get($o->values,$loop->index)) ? $x : '['.__('NEW').']' }}" readonly="true">
|
||||
<div class="invalid-feedback pb-2">
|
||||
@if($e)
|
||||
{{ join('|',$e) }}
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
{{ $value }}
|
||||
@if ($o->isStructural($value))
|
||||
|
@ -4,7 +4,14 @@
|
||||
<div id="{{ $o->name_lc }}">
|
||||
@foreach (old($o->name_lc,$o->values) as $value)
|
||||
@if ($edit)
|
||||
<input type="password" class="form-control mb-1 @if($x=($o->values->search($value) === FALSE)) border-focus @endif" type="text" name="{{ $o->name_lc }}[]" value="{{ str_repeat('*',10) }}" readonly="true">
|
||||
<div class="input-group has-validation">
|
||||
<input type="password" class="form-control @if($e=$errors->get($o->name_lc.'.'.$loop->index))is-invalid @endif mb-1 @if($o->values->search($value) === FALSE) border-focus @endif" name="{{ $o->name_lc }}[]" value="{{ str_repeat('*',10) }}" readonly="true">
|
||||
<div class="invalid-feedback pb-2">
|
||||
@if($e)
|
||||
{{ join('|',$e) }}
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
{{ $value }}<br>
|
||||
@endif
|
||||
|
@ -75,7 +75,7 @@
|
||||
<div class="tab-content">
|
||||
<!-- All Attributes -->
|
||||
<div class="tab-pane active" id="attributes" role="tabpanel">
|
||||
<form id="form-entry" method="POST" action="{{ url('entry/update') }}">
|
||||
<form id="form-entry" method="POST" class="needs-validation" action="{{ url('entry/update') }}" novalidate>
|
||||
@csrf
|
||||
|
||||
<input type="hidden" name="dn" value="{{ $o->getDNSecure() }}">
|
||||
|
Loading…
Reference in New Issue
Block a user