Skip to content

Commit

Permalink
Allow sympathizers BDE to access to esCadre app (#10227)
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed May 16, 2024
1 parent e510580 commit fd84a7d
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 48 deletions.
9 changes: 0 additions & 9 deletions features/firewall.feature
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,3 @@ Feature:
| _login_password | secret!12345 |
When I press "Connexion"
Then I should be on "/evenements"

Scenario: As a JeMengage user I cannot login by form
Given I am on "/connexion"
And I fill in the following:
| _login_email | je-mengage-user-1@en-marche-dev.fr |
| _login_password | secret!12345 |
When I press "Connexion"
Then I should be on "/connexion"
And I should see "L'adresse email et le mot de passe que vous avez saisis ne correspondent pas."
11 changes: 0 additions & 11 deletions src/Repository/AdherentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -1371,17 +1371,6 @@ public function findAdherentByAutocompletion(AdherentAutocompleteFilter $filter,

if ($filter->type) {
MembershipFilterHelper::withMembershipFilter($qb, 'a', $filter->type);
} else {
$qb
->andWhere((new Orx())
->add('a.source IS NULL AND a.adherent = :true')
->add('a.source = :source_jme')
->add('a.source = :source_renaissance')
)
->setParameter('true', true)
->setParameter('source_jme', MembershipSourceEnum::JEMENGAGE)
->setParameter('source_renaissance', MembershipSourceEnum::RENAISSANCE)
;
}

return $qb
Expand Down
23 changes: 4 additions & 19 deletions src/Security/LoginFormGuardAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\BesoinDEurope\Inscription\FinishInscriptionRedirectHandler;
use App\Entity\Adherent;
use App\Entity\FailedLoginAttempt;
use App\Membership\MembershipSourceEnum;
use App\OAuth\App\AuthAppUrlManager;
use App\Repository\FailedLoginAttemptRepository;
use App\Security\Http\Session\AnonymousFollowerSession;
Expand Down Expand Up @@ -102,19 +101,7 @@ public function getUser($credentials, UserProviderInterface $userProvider)
/** @param UserInterface|Adherent $user */
public function checkCredentials($credentials, UserInterface $user)
{
if (!$this->passwordEncoder->isPasswordValid($user, $credentials['password'])) {
return false;
}

if (
null !== $user->getSource()
&& MembershipSourceEnum::RENAISSANCE !== $user->getSource()
&& $this->currentAppCode !== $user->getSource()
) {
return false;
}

return true;
return $this->passwordEncoder->isPasswordValid($user, $credentials['password']);
}

public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
Expand All @@ -123,16 +110,14 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token,
return $this->anonymousFollowerSession->terminate();
}

$targetPath = $this->getTargetPath($request->getSession(), $providerKey);
if ($targetPath = $this->getTargetPath($request->getSession(), $providerKey)) {
return new RedirectResponse($targetPath);
}

if ($redirect = $this->besoinDEuropeRedirectHandler->redirectToCompleteInscription($targetPath)) {
return $redirect;
}

if ($targetPath) {
return new RedirectResponse($targetPath);
}

/** @var Adherent $adherent */
$user = $token->getUser();

Expand Down
1 change: 0 additions & 1 deletion src/Validator/MyTeamMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
*/
class MyTeamMember extends Constraint
{
public $messageInvalidAdherentSource = "Ce militant ne peut pas être ajouter à l'équipe.";
public $messageCurrentUser = 'Vous ne pouvez pas ajouter votre compte ou le compte qui vous a délégué l\'accès';
}
8 changes: 0 additions & 8 deletions src/Validator/MyTeamMemberValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ public function validate($value, Constraint $constraint): void
return;
}

if (null !== $value->getSource() && !$value->isJemengageUser() && !$value->isRenaissanceUser()) {
$this
->context
->buildViolation($constraint->messageInvalidAdherentSource)
->addViolation()
;
}

if (!$scope = $this->scopeGeneratorResolver->generate()) {
return;
}
Expand Down

0 comments on commit fd84a7d

Please sign in to comment.