diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index 91728bb..aedcf16 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -826,11 +826,11 @@ class SystemController extends Controller if ($request->isMethod('GET')) return view('user.system.register'); - if ($request->action === 'register' && $request->system_id) + if ($request->action === 'register' && $request->name && is_numeric($request->name)) return view('user.system.widget.register_confirm') - ->with('o',System::findOrFail($request->system_id)); + ->with('o',System::findOrFail($request->name)); - $o = System::findOrNew($request->system_id); + $o = System::findOrNew(is_numeric($request->system_id) ? $request->system_id : NULL); // If the system exists, and we are 'register', we'll start the address claim process if ($o->exists && $request->action === 'Link') { diff --git a/app/Http/Requests/SystemRegister.php b/app/Http/Requests/SystemRegister.php index 61b38e8..88a2536 100644 --- a/app/Http/Requests/SystemRegister.php +++ b/app/Http/Requests/SystemRegister.php @@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Gate; use Illuminate\Validation\Rule; use App\Classes\FTN\Packet; -use App\Models\System; +use App\Models\{Setup,System}; // @todo rename to SystemRegisterRequest class SystemRegister extends FormRequest @@ -22,9 +22,17 @@ class SystemRegister extends FormRequest */ public function authorize(Request $request) { - $this->so = System::findOrNew($request->system_id); + $this->so = new System; - return Gate::allows($this->so->users->count() ? 'update' : 'register',$this->so); + if (is_numeric($request->name)) { + $this->so = System::findOrNew($request->name); + + // Cannot claim this site + if ($this->so->id === Setup::findOrFail(config('app.id'))->system_id) + return FALSE; + } + + return Gate::allows(is_numeric($request->name) && $this->so->users->count() ? 'update' : 'register',$this->so); } public function messages(): array diff --git a/resources/views/user/system/register.blade.php b/resources/views/user/system/register.blade.php index 702de49..eba1e13 100644 --- a/resources/views/user/system/register.blade.php +++ b/resources/views/user/system/register.blade.php @@ -19,12 +19,18 @@
- - - -
+ + - @error('name') + @error('system_id') {{ $message }} @else BBS Name is required. @@ -66,45 +72,20 @@ @endsection @section('page-css') - + @css('select2') @append @section('page-scripts') + @js('select2') + + + @append \ No newline at end of file