Update on security, user to edit their own system
This commit is contained in:
@@ -22,17 +22,14 @@ class SystemRegister extends FormRequest
|
||||
*/
|
||||
public function authorize(Request $request)
|
||||
{
|
||||
$this->so = new System;
|
||||
if (! $request->post())
|
||||
return TRUE;
|
||||
|
||||
if (is_numeric($request->name)) {
|
||||
$this->so = System::findOrNew($request->name);
|
||||
// Cannot claim this site
|
||||
if ($this->route('o')->id === Setup::findOrFail(config('app.id'))->system_id)
|
||||
return FALSE;
|
||||
|
||||
// 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);
|
||||
return Gate::allows($this->route('o')->users->count() ? 'update_nn' : 'register',$this->route('o'));
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
|
35
app/Http/Requests/SystemSessionRequest.php
Normal file
35
app/Http/Requests/SystemSessionRequest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class SystemSessionRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
session()->flash('accordion','session');
|
||||
return Gate::allows('update_nn',$this->route('o'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'zone_id' => 'required|exists:zones,id',
|
||||
'sespass' => 'required|string|min:4',
|
||||
'pktpass' => 'required|string|min:4|max:8',
|
||||
'ticpass' => 'required|string|min:4',
|
||||
'fixpass' => 'required|string|min:4',
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user