Skip to content

Commit

Permalink
Fix Vox magic link email (#10716)
Browse files Browse the repository at this point in the history
* Fix Vox magic link email

* Adjust adhesion page
  • Loading branch information
ottaviano committed Sep 11, 2024
1 parent ae96d8d commit aa523bc
Show file tree
Hide file tree
Showing 21 changed files with 22 additions and 854 deletions.
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ APP_DEBUG=false
APP_HOST=test.enmarche.code
RENAISSANCE_HOST=test.renaissance.code
APP_RENAISSANCE_HOST=test.renaissance.code
USER_VOX_HOST=test.renaissance.code
WEBHOOK_RENAISSANCE_HOST=test.renaissance.code
PROCURATION_HOST=test.enmarche.code
LEGISLATIVES_AVECVOUS_HOST=test.enmarche.code
Expand Down
14 changes: 2 additions & 12 deletions config/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ app_assets:
type: "annotation"
host: "{app_domain}"
defaults:
app_domain: "%app_renaissance_host%"
app_domain: "%user_vox_host%"
requirements:
app_domain: "%app_host%|%app_renaissance_host%|%national_event_host%|%user_vox_host%"

Expand Down Expand Up @@ -252,20 +252,10 @@ app_webhook_renaissance:
type: "annotation"

app_renaissance:
host: "%app_renaissance_host%"
host: "%user_vox_host%"
resource: "../src/Controller/Renaissance"
type: "annotation"

app_adherent_elected_contribution:
host: "%user_vox_host%"
resource: "../src/Controller/Renaissance/Adherent/Contribution"
type: "annotation"

app_adhesion:
host: "%user_vox_host%"
resource: "../src/Controller/Renaissance/Adhesion"
type: "annotation"

app_besoindeurope:
host: "%user_vox_host%"
resource: "../src/Controller/BesoinDEurope"
Expand Down
1 change: 0 additions & 1 deletion config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ services:
$renaissanceHost: '%app_renaissance_host%'
$adminRenaissanceHost: '%admin_renaissance_host%'
$jemengageHost: '%jemengage_host%'
$jemengageAuthHost: '%jemengage_auth_host%'
$avecvousHost: '%avecvous_host%'
$userBesoinDEuropeHost: '%env(USER_BESOINDEUROPE_HOST)%'
$userVoxHost: '%user_vox_host%'
Expand Down
2 changes: 1 addition & 1 deletion features/api/membership_avecvous.feature
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Feature:
"global_merge_vars": [
{
"name": "create_password_link",
"content": "http://utilisateur.renaissance.code/changer-mot-de-passe/@string@/@string@"
"content": "http://test.renaissance.code/changer-mot-de-passe/@string@/@string@"
}
],
"to": [
Expand Down
4 changes: 2 additions & 2 deletions features/api/membership_jemengage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Feature:
},
{
"name": "create_password_link",
"content": "http://utilisateur.renaissance.code/changer-mot-de-passe/@string@/@string@"
"content": "http://test.renaissance.code/changer-mot-de-passe/@string@/@string@"
}
],
"from_name": "Je m'engage",
Expand Down Expand Up @@ -124,7 +124,7 @@ Feature:
},
{
"name": "reset_link",
"content": "http://utilisateur.renaissance.code/changer-mot-de-passe/@string@/@string@"
"content": "http://test.renaissance.code/changer-mot-de-passe/@string@/@string@"
}
],
"from_name": "Renaissance",
Expand Down
18 changes: 1 addition & 17 deletions src/AppCodeEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,16 @@ final class AppCodeEnum extends Enum
public const BESOIN_D_EUROPE = 'besoindeurope';
public const LEGISLATIVE = 'legislative';
public const VOX = 'vox';
public const JEMENGAGE = 'jemengage';
public const JEMENGAGE_WEB = 'jemengage_web';
public const JEMENGAGE_MOBILE = 'jemengage_mobile';

public static function getJemangageAppCodes(): array
{
return [
self::JEMENGAGE,
self::JEMENGAGE_WEB,
self::JEMENGAGE_MOBILE,
self::BESOIN_D_EUROPE,
];
}

public static function isJeMengage(?string $code): bool
{
return \in_array($code, static::getJemangageAppCodes(), true);
}

public static function isRenaissanceApp(?string $code): bool
{
return self::RENAISSANCE === $code;
}

public static function isMobileApp(?string $appCode): bool
{
return \in_array($appCode, [self::BESOIN_D_EUROPE, self::LEGISLATIVE]);
return \in_array($appCode, [self::BESOIN_D_EUROPE, self::LEGISLATIVE, self::VOX]);
}
}
73 changes: 0 additions & 73 deletions src/BesoinDEurope/App/UrlGenerator.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Controller/Renaissance/Adhesion/AdhesionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __invoke(Request $request): Response
if (($currentUser = $this->getUser()) instanceof Adherent && $currentUser->hasActiveMembership()) {
$this->addFlash('success', 'Vous êtes déjà à jour de cotisation.');

return $this->redirectToRoute('app_renaissance_adherent_space');
return $this->redirectToRoute('vox_app_redirect');
}

/** @var MembershipRequest $membershipRequest */
Expand Down
19 changes: 0 additions & 19 deletions src/Controller/Renaissance/HomeController.php

This file was deleted.

16 changes: 4 additions & 12 deletions src/Controller/Renaissance/MagicLinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\AppCodeEnum;
use App\Entity\Administrator;
use App\Mailer\MailerService;
use App\Mailer\Message\Ensemble\EnsembleMagicLinkMessage;
use App\Mailer\Message\Renaissance\RenaissanceMagicLinkMessage;
use App\OAuth\App\AuthAppUrlManager;
use App\Repository\AdherentRepository;
Expand All @@ -27,16 +26,13 @@ public function getMagicLinkAction(
AdherentRepository $adherentRepository,
MailerService $transactionalMailer,
TranslatorInterface $translator,
AuthAppUrlManager $appUrlManager,
): Response {
$appUrlGenerator = $appUrlManager->getUrlGenerator($appCode = $appUrlManager->getAppCodeFromRequest($request) ?? AppCodeEnum::RENAISSANCE);

if ($user = $this->getUser()) {
if ($user instanceof Administrator) {
return $this->redirectToRoute('admin_app_adherent_list');
}

return $this->redirect($appUrlGenerator->generateForLoginSuccess($user));
return $this->redirectToRoute('vox_app_redirect');
}

$form = $this
Expand All @@ -48,18 +44,14 @@ public function getMagicLinkAction(
$email = $form->getData();

if ($adherent = $adherentRepository->findOneActiveByEmail($email)) {
$loginLink = $loginLinkHandler->createLoginLink($adherent, $request, $appCode);
$loginLink = $loginLinkHandler->createLoginLink($adherent, $request, AppCodeEnum::VOX);

if (AppCodeEnum::isMobileApp($appCode)) {
$transactionalMailer->sendMessage(EnsembleMagicLinkMessage::create($adherent, $loginLink->getUrl()));
} else {
$transactionalMailer->sendMessage(RenaissanceMagicLinkMessage::create($adherent, $loginLink->getUrl()));
}
$transactionalMailer->sendMessage(RenaissanceMagicLinkMessage::create($adherent, $loginLink->getUrl()));
}

$this->addFlash('info', $translator->trans('adherent.get_magic_link.email_sent', ['%email%' => $email]));

return $this->redirectToRoute('app_user_get_magic_link', ['app_domain' => $appUrlGenerator->getAppHost()]);
return $this->redirectToRoute('app_user_get_magic_link');
}

return $this->render('security/renaissance_user_magic_link.html.twig', ['form' => $form->createView()]);
Expand Down
5 changes: 0 additions & 5 deletions src/Entity/Adherent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2170,11 +2170,6 @@ public function setSource(?string $source): void
$this->source = $source;
}

public function isJemengageUser(): bool
{
return MembershipSourceEnum::JEMENGAGE === $this->source;
}

public function isRenaissanceUser(): bool
{
return MembershipSourceEnum::RENAISSANCE === $this->source;
Expand Down
60 changes: 0 additions & 60 deletions src/JeMengage/App/AppUrlGenerator.php

This file was deleted.

21 changes: 0 additions & 21 deletions src/Mailer/Message/Ensemble/EnsembleMagicLinkMessage.php

This file was deleted.

3 changes: 2 additions & 1 deletion src/OAuth/App/AuthAppUrlManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\OAuth\App;

use App\AppCodeEnum;
use Symfony\Component\HttpFoundation\Request;

class AuthAppUrlManager
Expand All @@ -16,7 +17,7 @@ public function __construct(iterable $urlGenerators)

public function getUrlGenerator(string $appCode): AuthAppUrlGeneratorInterface
{
return $this->urlGenerators[$appCode];
return $this->urlGenerators[$appCode] ?? $this->urlGenerators[AppCodeEnum::RENAISSANCE];
}

public function getAppCodeFromRequest(Request $request): ?string
Expand Down
6 changes: 3 additions & 3 deletions src/Renaissance/App/UrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class UrlGenerator extends AbstractAppUrlGenerator
{
private string $appHost;

public function __construct(UrlGeneratorInterface $urlGenerator, string $renaissanceHost)
public function __construct(UrlGeneratorInterface $urlGenerator, string $userVoxHost)
{
parent::__construct($urlGenerator);

$this->appHost = $renaissanceHost;
$this->appHost = $userVoxHost;
}

public static function getAppCode(): string
Expand All @@ -31,7 +31,7 @@ public function generateHomepageLink(): string

public function generateForLoginSuccess(Adherent $adherent): string
{
return $this->urlGenerator->generate('app_renaissance_adherent_space');
return $this->urlGenerator->generate('vox_app_redirect');
}

public function generateSuccessResetPasswordLink(Request $request): string
Expand Down
Loading

0 comments on commit aa523bc

Please sign in to comment.