Poprawka przy usuwaniu/edycji uzytkownika
This commit is contained in:
parent
ec39ee9965
commit
6e4b651be3
@ -67,18 +67,20 @@
|
|||||||
{{ __('Anuluj') }}
|
{{ __('Anuluj') }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if(auth()->id() !== $user->id)
|
|
||||||
<form method="POST" action="{{ route('users.destroy', $user) }}" onsubmit="return confirm('Czy na pewno chcesz usunąć tego użytkownika?');">
|
|
||||||
@csrf
|
|
||||||
@method('DELETE')
|
|
||||||
<button type="submit" class="inline-flex items-center px-4 py-2 bg-red-600 hover:bg-red-500 text-white text-sm font-medium rounded-md shadow-sm transition">
|
|
||||||
{{ __('Usuń użytkownika') }}
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
@endif
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@if(auth()->id() !== $user->id)
|
||||||
|
<div class="mt-6 flex justify-end">
|
||||||
|
<form method="POST" action="{{ route('users.destroy', $user) }}" onsubmit="return confirm('Czy na pewno chcesz usunąć tego użytkownika?');">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button type="submit" class="inline-flex items-center px-4 py-2 bg-red-600 hover:bg-red-500 text-white text-sm font-medium rounded-md shadow-sm transition">
|
||||||
|
{{ __('Usuń użytkownika') }}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -42,3 +42,24 @@ test('deleted users can be listed and restored', function () {
|
|||||||
$restoreResponse->assertRedirect(route('users.deleted'));
|
$restoreResponse->assertRedirect(route('users.deleted'));
|
||||||
$this->assertNull($user->fresh()->deleted_at);
|
$this->assertNull($user->fresh()->deleted_at);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('edit page does not render nested forms for user actions', function () {
|
||||||
|
Permission::firstOrCreate(['name' => 'users_access']);
|
||||||
|
|
||||||
|
$admin = User::factory()->create();
|
||||||
|
$adminRole = Role::firstOrCreate(['name' => 'admin']);
|
||||||
|
$admin->assignRole($adminRole);
|
||||||
|
$admin->givePermissionTo('users_access');
|
||||||
|
|
||||||
|
$user = User::factory()->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($admin)->get('/users/' . $user->id . '/edit');
|
||||||
|
$response->assertOk();
|
||||||
|
|
||||||
|
$html = $response->getContent();
|
||||||
|
|
||||||
|
$this->assertDoesNotMatchRegularExpression(
|
||||||
|
'/<form[^>]*action="[^"]*\/users\/' . preg_quote((string) $user->id, '/') . '[^"]*"[^>]*>(?:(?!<\/form>).)*<form\b/s',
|
||||||
|
$html
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user