Internal enhancements to system registration and editing
This commit is contained in:
@@ -7,8 +7,10 @@ use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\ViewErrorBag;
|
||||
|
||||
use App\Http\Requests\SystemRegister;
|
||||
use App\Models\{Address,Echoarea,System,SystemZone,Zone};
|
||||
use App\Rules\{FidoInteger,TwoByteInteger};
|
||||
|
||||
@@ -253,26 +255,9 @@ class SystemController extends Controller
|
||||
/**
|
||||
* Add or edit a node
|
||||
*/
|
||||
public function add_edit(Request $request,System $o)
|
||||
public function add_edit(SystemRegister $request,System $o)
|
||||
{
|
||||
if ($request->post()) {
|
||||
$this->authorize('admin',$o);
|
||||
|
||||
$request->validate([
|
||||
'name' => 'required|min:3',
|
||||
'location' => 'required|min:3',
|
||||
'sysop' => 'required|min:3',
|
||||
'phone' => 'nullable|regex:/^([0-9-]+)$/',
|
||||
'address' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i',
|
||||
'port' => 'nullable|digits_between:2,5',
|
||||
'method' => 'nullable|numeric',
|
||||
'mailer_type' => 'nullable|numeric',
|
||||
'mailer_address' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i',
|
||||
'mailer_port' => 'nullable|digits_between:2,5',
|
||||
'active' => 'required|boolean',
|
||||
'zt_id' => 'nullable|size:10|regex:/^([A-Fa-f0-9]){10}$/|unique:systems,zt_id,'.($o->exists ? $o->id : 0),
|
||||
]);
|
||||
|
||||
foreach (['name','location','sysop','phone','address','port','active','method','notes','mailer_type','mailer_address','mailer_port','zt_id'] as $key)
|
||||
$o->{$key} = $request->post($key);
|
||||
|
||||
@@ -283,8 +268,11 @@ class SystemController extends Controller
|
||||
|
||||
$o->load(['addresses.zone.domain']);
|
||||
|
||||
return view('system.addedit')
|
||||
->with('o',$o);
|
||||
return Gate::check('update',$o)
|
||||
? view('system.addedit')
|
||||
->with('action',$o->exists ? 'update' : 'create')
|
||||
->with('o',$o)
|
||||
: redirect()->to('user/system/register');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -448,7 +436,7 @@ class SystemController extends Controller
|
||||
/**
|
||||
* register system
|
||||
*/
|
||||
public function system_register(Request $request)
|
||||
public function system_register(SystemRegister $request)
|
||||
{
|
||||
$o = System::findOrNew($request->system_id);
|
||||
|
||||
@@ -465,12 +453,17 @@ class SystemController extends Controller
|
||||
if ($request->post('submit')) {
|
||||
Auth::user()->systems()->save($o);
|
||||
|
||||
// @todo if the system already exists and part of one of our nextworks, we'll need to send the registration email to confirm the address.
|
||||
// @todo if the system already exists and part of one of our networks, we'll need to send the registration email to confirm the address.
|
||||
// @todo mark the system (or addresses) as "pending" at this stage until it is confirmed
|
||||
return redirect()->to(url('ftn/system/addedit',$o->id));
|
||||
}
|
||||
|
||||
// Re-flash our previously input data
|
||||
if ($request->old)
|
||||
session()->flashInput($request->old);
|
||||
|
||||
return view('system.widget.form-system')
|
||||
->with('action',$request->action)
|
||||
->with('o',$o)
|
||||
->with('errors',new ViewErrorBag);
|
||||
}
|
||||
|
Reference in New Issue
Block a user