mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-05-13 06:29:24 -05:00
update: allow empty peer id prefix for client blacklist
Simple way to block all clients in emergencies.
This commit is contained in:
@@ -51,7 +51,10 @@ class BlacklistClientController extends Controller
|
||||
{
|
||||
Unit3dAnnounce::removeBlacklistedAgent($blacklistClient);
|
||||
|
||||
$blacklistClient->update($request->validated());
|
||||
$blacklistClient->update([
|
||||
// Overriding is necessary to cast empty strings (converted to null by middleware) back into strings
|
||||
'peer_id_prefix' => $request->string('peer_id_prefix'),
|
||||
] + $request->validated());
|
||||
|
||||
Unit3dAnnounce::addBlacklistedAgent($blacklistClient);
|
||||
|
||||
@@ -74,7 +77,10 @@ class BlacklistClientController extends Controller
|
||||
*/
|
||||
public function store(StoreBlacklistClientRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$client = BlacklistClient::create($request->validated());
|
||||
$client = BlacklistClient::create([
|
||||
// Overriding is necessary to cast empty strings (converted to null by middleware) back into strings
|
||||
'peer_id_prefix' => $request->string('peer_id_prefix'),
|
||||
] + $request->validated());
|
||||
|
||||
Unit3dAnnounce::addBlacklistedAgent($client);
|
||||
|
||||
|
||||
@@ -36,11 +36,10 @@ class StoreBlacklistClientRequest extends FormRequest
|
||||
'name' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
'unique:blacklist_clients',
|
||||
],
|
||||
'peer_id_prefix' => [
|
||||
'required',
|
||||
'string',
|
||||
'unique:blacklist_clients',
|
||||
],
|
||||
'reason' => [
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
namespace App\Http\Requests\Staff;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateBlacklistClientRequest extends FormRequest
|
||||
{
|
||||
@@ -30,17 +32,16 @@ class UpdateBlacklistClientRequest extends FormRequest
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\Rule|array<\Illuminate\Contracts\Validation\Rule|string>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
public function rules(Request $request): array
|
||||
{
|
||||
return [
|
||||
'name' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
Rule::unique('blacklist_clients')->ignore($request->route('blacklistClient')),
|
||||
],
|
||||
'peer_id_prefix' => [
|
||||
'required',
|
||||
'string',
|
||||
'unique:blacklist_clients',
|
||||
],
|
||||
'reason' => [
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
id="peer_id_prefix"
|
||||
class="form__text"
|
||||
name="peer_id_prefix"
|
||||
required
|
||||
placeholder=" "
|
||||
type="text"
|
||||
value="{{ old('peer_id_prefix') }}"
|
||||
/>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
id="peer_id_prefix"
|
||||
class="form__text"
|
||||
name="peer_id_prefix"
|
||||
required
|
||||
placeholder=" "
|
||||
type="text"
|
||||
value="{{ $client->peer_id_prefix }}"
|
||||
/>
|
||||
|
||||
@@ -30,6 +30,7 @@ test('rules', function (): void {
|
||||
'name' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
'unique:blacklist_clients',
|
||||
],
|
||||
'reason' => [
|
||||
|
||||
@@ -24,6 +24,8 @@ test('authorize', function (): void {
|
||||
});
|
||||
|
||||
test('rules', function (): void {
|
||||
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
|
||||
|
||||
$actual = $this->subject->rules();
|
||||
|
||||
$this->assertValidationRules([
|
||||
|
||||
Reference in New Issue
Block a user