Skip to content
Snippets Groups Projects
Commit 16080a87 authored by Sebastien's avatar Sebastien
Browse files

Merge branch...

Merge branch 'tuleap-96-a-registered-user-shouldn-t-be-able-to-access-the-register-page' into 'main'

Add a redirection to capsule_list in registration controller

See merge request !19
parents e3573da4 dabb9891
No related branches found
No related tags found
1 merge request!19Add a redirection to capsule_list in registration controller
...@@ -38,6 +38,10 @@ class RegistrationController extends AbstractController ...@@ -38,6 +38,10 @@ class RegistrationController extends AbstractController
UserPasswordHasherInterface $userPasswordHasher, UserPasswordHasherInterface $userPasswordHasher,
EntityManagerInterface $entityManager EntityManagerInterface $entityManager
): Response { ): Response {
if ($this->getUser()) {
return $this->redirectToRoute('capsule_list');
}
$user = new User(); $user = new User();
$form = $this->createForm(RegistrationFormType::class, $user); $form = $this->createForm(RegistrationFormType::class, $user);
$form->handleRequest($request); $form->handleRequest($request);
......
...@@ -77,6 +77,30 @@ class RegistrationControllerTest extends WebTestCase ...@@ -77,6 +77,30 @@ class RegistrationControllerTest extends WebTestCase
$this->assertResponseIsSuccessful('Once the user has validated his email, he should be on the login page'); $this->assertResponseIsSuccessful('Once the user has validated his email, he should be on the login page');
} }
public function testAnAuthenticatedUserShouldNotBeAbleToAccessTheRegisterPage(): void
{
$client = static::createClient();
$userRepository = static::getContainer()->get(UserRepository::class);
$testUser = $userRepository->findOneByEmail('defaultUser@localhost.com');
$client->loginUser($testUser);
$client->request('GET', '/register');
$this->assertResponseRedirects('/my_capsules', 302);
}
public function testAnAuthenticatedUserShouldNotBeAbleToAccessTheLoginPage(): void
{
$client = static::createClient();
$userRepository = static::getContainer()->get(UserRepository::class);
$testUser = $userRepository->findOneByEmail('defaultUser@localhost.com');
$client->loginUser($testUser);
$client->request('GET', '/login');
$this->assertResponseRedirects('/my_capsules', 302);
}
/** /**
* @param string $userEmail The registered user email * @param string $userEmail The registered user email
* @return RawMessage The email message sent to the user * @return RawMessage The email message sent to the user
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment