Fix for system registration, new systems couldnt be added.
This commit is contained in:
parent
51e915b73d
commit
c5500020ae
@ -580,7 +580,7 @@ class SystemController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register system
|
* Register a system, or link to an existing system
|
||||||
*/
|
*/
|
||||||
public function system_register(SystemRegister $request)
|
public function system_register(SystemRegister $request)
|
||||||
{
|
{
|
||||||
@ -588,14 +588,14 @@ class SystemController extends Controller
|
|||||||
if ($request->isMethod('GET'))
|
if ($request->isMethod('GET'))
|
||||||
return view('user.system.register');
|
return view('user.system.register');
|
||||||
|
|
||||||
if ($request->action != 'create')
|
if ($request->action === 'register' && $request->system_id)
|
||||||
return view('user.system.widget.register_confirm')
|
return view('user.system.widget.register_confirm')
|
||||||
->with('o',System::findOrFail($request->system_id));
|
->with('o',System::findOrFail($request->system_id));
|
||||||
|
|
||||||
$o = System::findOrNew($request->system_id);
|
$o = System::findOrNew($request->system_id);
|
||||||
|
|
||||||
// If the system exists, and we are 'register', we'll start the address claim process
|
// If the system exists, and we are 'register', we'll start the address claim process
|
||||||
if ($o->exists && $request->action == 'register') {
|
if ($o->exists && $request->action === 'Link') {
|
||||||
$validate = Setup::findOrFail(config('app.id'))->system->inMyZones($o->addresses);
|
$validate = Setup::findOrFail(config('app.id'))->system->inMyZones($o->addresses);
|
||||||
|
|
||||||
// If we have addresses, we'll trigger the routed netmail
|
// If we have addresses, we'll trigger the routed netmail
|
||||||
|
@ -12,39 +12,41 @@ class SystemRegister extends FormRequest
|
|||||||
{
|
{
|
||||||
private System $so;
|
private System $so;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the user is authorized to make this request.
|
* Determine if the user is authorized to make this request.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function authorize(Request $request)
|
public function authorize(Request $request)
|
||||||
{
|
{
|
||||||
$this->so = System::findOrNew($request->system_id);
|
$this->so = System::findOrNew($request->system_id);
|
||||||
|
|
||||||
return Gate::allows($this->so->users->count() ? 'update' : 'register',$this->so);
|
return Gate::allows($this->so->users->count() ? 'update' : 'register',$this->so);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
* @return array
|
* If the system exists (POST & action="register" & system_id=<value>), then no validation required
|
||||||
*/
|
* If the system doesnt exist (POST & action="register" & system_id undefined) then we need just a name to start the process (action="create")
|
||||||
public function rules(Request $request)
|
* Then, full validation
|
||||||
{
|
* @return array
|
||||||
if ((! $request->isMethod('post')) || ($request->action == 'register'))
|
*/
|
||||||
|
public function rules(Request $request)
|
||||||
|
{
|
||||||
|
if ((! $request->isMethod('post')) || ($request->action === 'register'))
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
if ((! $this->so->exists) && ($request->action == 'create')) {
|
if ((! $this->so->exists) && ($request->action === 'create'))
|
||||||
return [
|
return [
|
||||||
'name' => 'required|min:3',
|
'name' => 'required|min:3',
|
||||||
];
|
];
|
||||||
}
|
|
||||||
|
|
||||||
return array_filter(array_merge(
|
return array_filter(array_merge(
|
||||||
[
|
[
|
||||||
'name' => 'required|min:3',
|
'name' => 'required|min:3',
|
||||||
],
|
],
|
||||||
($this->so->exists || ($request->action != 'create')) ? [
|
($this->so->exists || ($request->action !== 'create')) ? [
|
||||||
'location' => 'required|min:3',
|
'location' => 'required|min:3',
|
||||||
|
|
||||||
'sysop' => 'required|min:3',
|
'sysop' => 'required|min:3',
|
||||||
@ -62,5 +64,5 @@ class SystemRegister extends FormRequest
|
|||||||
'hold' => 'required|boolean',
|
'hold' => 'required|boolean',
|
||||||
] : [],
|
] : [],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -34,7 +34,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (old('submit') != 'create')
|
@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>
|
||||||
@ -131,7 +131,7 @@
|
|||||||
switch (data.status) {
|
switch (data.status) {
|
||||||
case 200:
|
case 200:
|
||||||
// if json is null, means no match, won't do again.
|
// if json is null, means no match, won't do again.
|
||||||
if(data.responseText==null || (data.responseText.length===0)) return;
|
if(data.responseText===null || (data.responseText.length===0)) return;
|
||||||
$('#create').empty().append(data.responseText);
|
$('#create').empty().append(data.responseText);
|
||||||
|
|
||||||
@if($errors->count())
|
@if($errors->count())
|
||||||
@ -166,7 +166,7 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if ({{ old('submit') == 'create' ? 'true' : 'false' }}) {
|
if ({{ old('submit') === 'create' ? 'true' : 'false' }}) {
|
||||||
getform();
|
getform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user