diff --git a/app/Classes/LDAP/Schema/AttributeType.php b/app/Classes/LDAP/Schema/AttributeType.php index acaa319..28c79ed 100644 --- a/app/Classes/LDAP/Schema/AttributeType.php +++ b/app/Classes/LDAP/Schema/AttributeType.php @@ -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); } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 9ec4bee..e24d431 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -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') diff --git a/app/Http/Requests/EntryRequest.php b/app/Http/Requests/EntryRequest.php index a57b07e..5aba0c7 100644 --- a/app/Http/Requests/EntryRequest.php +++ b/app/Http/Requests/EntryRequest.php @@ -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(); } } \ No newline at end of file diff --git a/config/ldap.php b/config/ldap.php index d4b141f..4596e61 100644 --- a/config/ldap.php +++ b/config/ldap.php @@ -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']], + ], ]; diff --git a/public/css/fixes.css b/public/css/fixes.css index 8430e33..2918683 100644 --- a/public/css/fixes.css +++ b/public/css/fixes.css @@ -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; } \ No newline at end of file diff --git a/resources/views/components/attribute.blade.php b/resources/views/components/attribute.blade.php index d1b3043..65f4163 100644 --- a/resources/views/components/attribute.blade.php +++ b/resources/views/components/attribute.blade.php @@ -4,7 +4,14 @@
-
-
+@if($edit)
+
+@endif
- @if($edit)
- @lang('Delete') - @endif - |
- @endswitch
- @endforeach
-
+
+
+
+ @if($edit)
+ @lang('Delete') + @endif + |
+ @endswitch
+ @endforeach
+