diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index 5e35ac5..c9eee93 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -45,6 +45,7 @@ class SystemController extends Controller default: $o->pollmode = NULL; } + $o->active = (! is_null($x=$request->validated('active'))) && $x; $o->autohold = FALSE; $o->save(); @@ -60,7 +61,9 @@ class SystemController extends Controller $o->users()->detach(); } - return redirect()->to('system'); + return redirect() + ->to('system/addedit/'.$o->id) + ->with('saved',TRUE); } $o->load(['addresses.zone.domain','addresses.nodes_hub','addresses.system','sessions.domain','sessions.systems']); diff --git a/app/Http/Requests/SystemRegisterRequest.php b/app/Http/Requests/SystemRegisterRequest.php index 6d79482..aa77743 100644 --- a/app/Http/Requests/SystemRegisterRequest.php +++ b/app/Http/Requests/SystemRegisterRequest.php @@ -8,7 +8,6 @@ use Illuminate\Support\Facades\Gate; use Illuminate\Validation\Rule; use App\Classes\FTN\Packet; -use App\Models\Setup; class SystemRegisterRequest extends FormRequest { @@ -19,12 +18,10 @@ class SystemRegisterRequest extends FormRequest */ public function authorize(Request $request) { - if (! $request->post()) + if (! $request->post() || (! $this->route('o'))) return TRUE; - // Cannot claim this site - if ($this->route('o')->id === Setup::findOrFail(config('app.id'))->system_id) - return FALSE; + // @todo Also disallow claiming this hosts system return Gate::allows($this->route('o')->users->count() ? 'update_nn' : 'register',$this->route('o')); } diff --git a/resources/views/system/addedit.blade.php b/resources/views/system/addedit.blade.php index 4721f39..99ec9d0 100644 --- a/resources/views/system/addedit.blade.php +++ b/resources/views/system/addedit.blade.php @@ -14,6 +14,7 @@ use App\Models\Address;
This system is aware of the following systems - @can('create',(new \App\Models\System))(you can register more):@endcan - @can('admin',(new \App\Models\System))(you can add more):@endcan + @can('create',(new System))(you can register more):@endcan + @can('admin',(new System))(you can add more):@endcan
- @if (\App\Models\System::active()->count() === 0) - @can('create',(new \App\Models\System)) + @if (System::active()->count() === 0) + @can('create',(new System))There are no systems setup, to set up your first.
@elseThere are no systems - you need to ask an admin to create one for you.
@@ -40,7 +44,7 @@ - @foreach (\App\Models\System::active()->with(['addresses.zone.domain'])->get() as $oo) + @foreach (System::active()->with(['addresses.zone.domain'])->get() as $oo)