Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new renaissance adherent role #7921

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,9 @@ security:
entry_point: App\Security\LoginFormGuardAuthenticator

access_control:
- { path: '^/parametres', roles: [ROLE_USER] }
- { path: '^/espace-adherent', roles: [ROLE_ADHERENT] }
- { path: '^/parametres', host: '%app_host%', roles: [ROLE_USER] }
- { path: '^/espace-adherent', host: '%app_host%', roles: [ROLE_ADHERENT] }
- { path: '^/(espace-adherent|parametres)', host: '%renaissance_host%', roles: [ROLE_RENAISSANCE_ADHERENT] }
- { path: '^/admin/login', roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
- { path: '^/admin/(2fa|logout)', role: [IS_AUTHENTICATED_2FA_IN_PROGRESS] }
- { path: '^/admin', roles: [ROLE_ADMIN_DASHBOARD] }
Expand Down
4 changes: 0 additions & 4 deletions src/Controller/EnMarche/AdherentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ public function pinInterestsAction(
return $this->render('adherent/renaissance_profile.html.twig');
}

if ($isRenaissanceApp && !$adherent->isRenaissanceUser()) {
return $this->redirectToRoute('homepage');
}

$form = $this
->createForm(AdherentInterestsFormType::class, $adherent)
->handleRequest($request)
Expand Down
4 changes: 0 additions & 4 deletions src/Controller/EnMarche/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ public function profileAction(
return $this->render('adherent/renaissance_profile.html.twig');
}

if ($isRenaissanceApp && !$adherent->isRenaissanceUser()) {
return $this->redirect($this->generateUrl('homepage', [], UrlGeneratorInterface::ABSOLUTE_URL));
}

$adherentProfile = AdherentProfile::createFromAdherent($adherent);

$form = $this
Expand Down
2 changes: 0 additions & 2 deletions src/Controller/Renaissance/Formation/DownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
use App\Storage\FileRequestHandler;
use Doctrine\ORM\EntityManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
* @Route("/espace-adherent/formations/{id}/telecharger", name="app_renaissance_adherent_formation_download", methods={"GET"})
* @Entity("formation", expr="repository.findOneVisible(id)")
* @IsGranted("RENAISSANCE_ADHERENT")
*/
class DownloadController extends AbstractController
{
Expand Down
2 changes: 0 additions & 2 deletions src/Controller/Renaissance/Formation/ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

use App\Entity\Adherent;
use App\Repository\AdherentFormation\FormationRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
* @Route("/espace-adherent/formations", name="app_renaissance_adherent_formation_list", methods={"GET"})
* @IsGranted("RENAISSANCE_ADHERENT")
*/
class ListController extends AbstractController
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* @Route("/elections-departementales", name="app_renaissance_departmental_election_lists", methods="GET")
* @IsGranted("ROLE_ADHERENT")
* @IsGranted("ROLE_RENAISSANCE_ADHERENT")
*/
class CandidaciesListController extends AbstractController
{
Expand Down
22 changes: 10 additions & 12 deletions src/Entity/Adherent.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\Encoder\EncoderAwareInterface;
use Symfony\Component\Security\Core\User\EquatableInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Serializer\Annotation\Groups;
Expand Down Expand Up @@ -105,7 +103,7 @@
*
* @UniqueTerritorialCouncilMember(qualities={"referent", "lre_manager", "referent_jam"})
*/
class Adherent implements UserInterface, UserEntityInterface, GeoPointInterface, EncoderAwareInterface, MembershipInterface, ReferentTaggableEntity, ZoneableEntity, EntityMediaInterface, EquatableInterface, UuidEntityInterface, MailchimpCleanableContactInterface, PasswordAuthenticatedUserInterface
class Adherent implements UserInterface, UserEntityInterface, GeoPointInterface, MembershipInterface, ReferentTaggableEntity, ZoneableEntity, EntityMediaInterface, UuidEntityInterface, MailchimpCleanableContactInterface, PasswordAuthenticatedUserInterface
{
use EntityCrudTrait;
use EntityIdentityTrait;
Expand Down Expand Up @@ -1031,6 +1029,10 @@ public function getRoles()
$roles[] = 'ROLE_ADHERENT';
}

if ($this->isRenaissanceAdherent()) {
$roles[] = 'ROLE_RENAISSANCE_ADHERENT';
}

if ($this->isReferent()) {
$roles[] = 'ROLE_REFERENT';
}
Expand Down Expand Up @@ -1249,22 +1251,18 @@ public function hasLegacyPassword(): bool
return null !== $this->oldPassword;
}

public function getEncoderName(): ?string
public function getSalt()
{
if ($this->hasLegacyPassword()) {
return 'legacy_encoder';
}

return null;
}

public function getSalt()
public function getUserIdentifier(): string
{
return $this->emailAddress;
}

public function getUsername()
public function getUsername(): string
{
return $this->emailAddress;
return $this->getUserIdentifier();
}

public function eraseCredentials()
Expand Down
20 changes: 0 additions & 20 deletions src/Security/Voter/RenaissanceAdherentVoter.php

This file was deleted.

3 changes: 0 additions & 3 deletions tests/Controller/EnMarche/CommitteeControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ public function testAuthenticatedCommitteeHostCanUnfollowCommittee()

$crawler = $this->client->request(Request::METHOD_GET, $committeeUrl);

// Ex-host should be allow to follow again
$this->assertTrue($this->seeFollowLink($crawler));

$this->logout($this->client);
$this->getEntityManager(Adherent::class)->clear();

Expand Down
3 changes: 1 addition & 2 deletions tests/Controller/Renaissance/AdherentControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public function testProfileActionIsNotAccessibleForEMAdherent(string $profilePag

$this->client->request(Request::METHOD_GET, $profilePage);

$this->assertResponseStatusCode(Response::HTTP_FOUND, $this->client->getResponse());
$this->assertClientIsRedirectedTo('http://test.enmarche.code/', $this->client, false);
$this->assertResponseStatusCode(Response::HTTP_FORBIDDEN, $this->client->getResponse());
}

public function provideProfilePage(): \Generator
Expand Down