Skip to content
Snippets Groups Projects
Commit 65851326 authored by Camille Simiand's avatar Camille Simiand
Browse files

Fix - Non authenticated user can't access capsule list page

Instead, he's being redirected to the login page.
parent 9bef5298
No related branches found
No related tags found
1 merge request!21Fix - Non authenticated user can't access capsule list page
......@@ -13,6 +13,10 @@ class CapsuleController extends AbstractController
*/
public function index(): Response
{
if (! $this->getUser()) {
return $this->redirectToRoute('app_login');
}
return $this->render('capsule/index.html.twig', [
'controller_name' => 'CapsuleController',
]);
......
<?php
namespace App\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class CapsuleControllerTest extends WebTestCase
{
public function testANonAuthenticatedUserShouldNotBeAbleToAccessTheCapsuleListPage(): void
{
$client = static::createClient();
$client->request('GET', '/my_capsules');
$this->assertResponseRedirects("/login", 302);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment