Fix System registration form presentation and validation processing
This commit is contained in:
parent
1a5c1eff7b
commit
6e376100a5
@ -793,7 +793,7 @@ class SystemController extends Controller
|
|||||||
if ($request->old)
|
if ($request->old)
|
||||||
session()->flashInput($request->old);
|
session()->flashInput($request->old);
|
||||||
|
|
||||||
return view('system.widget.form-system')
|
return view('system.widget.system')
|
||||||
->with('action',$request->action)
|
->with('action',$request->action)
|
||||||
->with('o',$o)
|
->with('o',$o)
|
||||||
->with('errors',new ViewErrorBag);
|
->with('errors',new ViewErrorBag);
|
||||||
|
@ -53,21 +53,16 @@ class SystemRegister extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function rules(Request $request)
|
public function rules(Request $request)
|
||||||
{
|
{
|
||||||
if ((! $request->isMethod('post')) || ($request->action === 'register'))
|
// When the user first select register/link (get)
|
||||||
|
if (! $request->isMethod('post'))
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
$so = $this->route('o');
|
$so = $this->route('o');
|
||||||
|
if ((! $so) && ($request->action === 'register'))
|
||||||
|
return [];
|
||||||
|
|
||||||
if (((! $so) || (! $so->exists)) && ($request->action === 'create'))
|
return array_filter(array_merge([
|
||||||
return [
|
|
||||||
'name' => 'required|min:3',
|
'name' => 'required|min:3',
|
||||||
];
|
|
||||||
|
|
||||||
return array_filter(array_merge(
|
|
||||||
[
|
|
||||||
'name' => 'required|min:3',
|
|
||||||
],
|
|
||||||
($so->exists || ($request->action !== 'create')) ? [
|
|
||||||
'location' => 'required|min:3',
|
'location' => 'required|min:3',
|
||||||
'sysop' => 'required|min:3',
|
'sysop' => 'required|min:3',
|
||||||
'phone' => 'nullable|regex:/^([0-9-]+)$/',
|
'phone' => 'nullable|regex:/^([0-9-]+)$/',
|
||||||
@ -76,16 +71,14 @@ class SystemRegister extends FormRequest
|
|||||||
'method' => 'nullable|numeric',
|
'method' => 'nullable|numeric',
|
||||||
'mailer_details.*' => 'nullable|array',
|
'mailer_details.*' => 'nullable|array',
|
||||||
'mailer_details.*.port' => 'nullable|digits_between:2,5',
|
'mailer_details.*.port' => 'nullable|digits_between:2,5',
|
||||||
'zt_id' => 'nullable|size:10|regex:/^([A-Fa-f0-9]){10}$/|unique:systems,zt_id,'.($so->exists ? $so->id : 0),
|
'zt_id' => 'nullable|size:10|regex:/^([A-Fa-f0-9]){10}$/|unique:systems,zt_id,'.($so ? $so->id : 0),
|
||||||
'pkt_type' => ['required',Rule::in(array_keys(Packet::PACKET_TYPES))],
|
'pkt_type' => ['required',Rule::in(array_keys(Packet::PACKET_TYPES))],
|
||||||
|
],($so && $so->exists) ? [
|
||||||
'users' => 'nullable|array|min:1|max:2',
|
'users' => 'nullable|array|min:1|max:2',
|
||||||
] : [],
|
|
||||||
$so->exists ? [
|
|
||||||
'active' => 'required|boolean',
|
'active' => 'required|boolean',
|
||||||
'hold' => 'required|boolean',
|
'hold' => 'required|boolean',
|
||||||
'pollmode' => 'required|integer|min:0|max:2',
|
'pollmode' => 'required|integer|min:0|max:2',
|
||||||
'heartbeat' => 'nullable|integer|min:0|max:48',
|
'heartbeat' => 'nullable|integer|min:0|max:48',
|
||||||
] : [],
|
] : []));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
<!-- $o = System::class -->
|
<!-- $o = System::class -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xl-9 col-12">
|
<div class="col-xl-9 col-12">
|
||||||
|
@can('admin',$o)
|
||||||
<div class="row pt-0">
|
<div class="row pt-0">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h4 class="mb-0 pb-2">System Users</h4>
|
<h4 class="mb-0 pb-2">System Users</h4>
|
||||||
@ -28,6 +29,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@endcan
|
||||||
|
|
||||||
<div class="row pt-4">
|
<div class="row pt-4">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@ -53,6 +55,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ZeroTier ID -->
|
<!-- ZeroTier ID -->
|
||||||
|
@can('admin',$o)
|
||||||
<div class="col-5">
|
<div class="col-5">
|
||||||
<label for="zt_id" class="form-label">ZeroTier ID</label>
|
<label for="zt_id" class="form-label">ZeroTier ID</label>
|
||||||
<div class="input-group has-validation">
|
<div class="input-group has-validation">
|
||||||
@ -65,6 +68,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -40,13 +40,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (old('submit') !== 'create')
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 pb-2">
|
<div class="col-12 pb-2">
|
||||||
<button type="button" name="submit" class="btn btn-success">Next</button><span id="next" class="m-2"><i class="spinner-border spinner-border-sm text-light d-none"></i></span>
|
<button type="button" name="submit" class="btn btn-success">Next</button><span id="next" class="m-2"><i class="spinner-border spinner-border-sm text-light d-none"></i></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -77,7 +75,7 @@
|
|||||||
@section('page-scripts')
|
@section('page-scripts')
|
||||||
@js('select2')
|
@js('select2')
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type='text/javascript'>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#system').select2({
|
$('#system').select2({
|
||||||
placeholder: 'See if your BBS exists',
|
placeholder: 'See if your BBS exists',
|
||||||
@ -86,7 +84,7 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script type='text/javascript'>
|
||||||
var system_id;
|
var system_id;
|
||||||
var noauth = new bootstrap.Modal(document.getElementById('no-auth'), {});
|
var noauth = new bootstrap.Modal(document.getElementById('no-auth'), {});
|
||||||
|
|
||||||
@ -96,6 +94,10 @@
|
|||||||
attr.parent().find('.invalid-feedback').empty().append(message);
|
attr.parent().find('.invalid-feedback').empty().append(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We have selected a BBS from the link/register form, and it's either a new entry or an existing one
|
||||||
|
* @param icon
|
||||||
|
*/
|
||||||
function getform(icon) {
|
function getform(icon) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : '{{ url('user/system/register') }}',
|
url : '{{ url('user/system/register') }}',
|
||||||
|
Loading…
Reference in New Issue
Block a user