Commit edd768ea by Damien Moulard

add message after pswd update & small code fixes

parent 61e6ce3e
......@@ -73,7 +73,6 @@ legend.required:after {
text-align: center;
text-decoration: none;
margin: 4px 2px;
/* margin: 6px 4px; */
border-radius: 50%;
}
......
......@@ -472,10 +472,12 @@ $(function() {
$(".paiementDate").toggle(this.checked);
});
// Reset value on page loading (in case of second try)
$("#formEncaissement_payment_code").val('');
if ($("form[name='formEncaissement']").length > 0) {
// Reset value on page loading (in case of second try)
$("#formEncaissement_payment_code").val('');
// Set payment summary on validation page
let paymentValidationSubheaderText = `${$("#formEncaissement_adherent option:selected").text()} - Montant : ${$("#formEncaissement_montant").val()}`;
$("#payment-validation-subheader").text(paymentValidationSubheaderText);
}
......
......@@ -39,6 +39,7 @@ use Symfony\Component\Security\Core\Security as Secur;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken;
use Symfony\Component\Security\Core\Security;
class IndexController extends AbstractController
{
......@@ -51,9 +52,20 @@ class IndexController extends AbstractController
private $session;
private $tokenStorage;
private $router;
public function __construct(EventDispatcherInterface $eventDispatcher, EntityManagerInterface $em, UserManagerInterface $userManager, CsrfTokenManagerInterface $tokenManager = null, GuardAuthenticatorHandler $guard, SessionInterface $session, LoginAuthenticator $authenticator, TokenStorageInterface $tokenStorage, RouterInterface $router)
{
private $security;
public function __construct(
EventDispatcherInterface $eventDispatcher,
EntityManagerInterface $em,
UserManagerInterface $userManager,
CsrfTokenManagerInterface $tokenManager = null,
GuardAuthenticatorHandler $guard,
SessionInterface $session,
LoginAuthenticator $authenticator,
TokenStorageInterface $tokenStorage,
RouterInterface $router,
Security $security
) {
$this->eventDispatcher = $eventDispatcher;
$this->em = $em;
$this->userManager = $userManager;
......@@ -63,7 +75,8 @@ class IndexController extends AbstractController
$this->session = $session;
$this->tokenStorage = $tokenStorage;
$this->router = $router;
}
$this->security = $security;
}
/**
* @Route("/", name="index")
......@@ -91,6 +104,18 @@ class IndexController extends AbstractController
$template = 'index_wordpress.html.twig';
}
if (
isset($_GET["upswd"])
&& $_GET["upswd"] == "success"
&& $this->security->isGranted('ROLE_ADHERENT')
&& $this->getParameter('tav_env') == true
) {
$this->addFlash(
'warning',
'Suite à la modification de votre mot de passe, pensez à mettre à jour votre code de paiment pour pouvoir effectuer des achats.'
);
}
return $this->render('@kohinos/' . $template, [
'news' => [],
'last_username' => $lastUsername,
......
......@@ -19,7 +19,6 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
class UserAdherentController extends FluxController
{
......@@ -163,7 +162,7 @@ class UserAdherentController extends FluxController
* @Route("/adherent/set-payment-code", name="adherentSetPaymentCode")
* @IsGranted("ROLE_ADHERENT")
*/
public function setPaymentCodeAction(Request $request, UserPasswordEncoderInterface $encoder)
public function setPaymentCodeAction(Request $request)
{
$adherent = $this->getUser()->getAdherent();
$form = $this->createForm(SetPaymentCodeFormType::class, $adherent);
......
......@@ -29,7 +29,6 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Twig\Environment;
class UserController extends AbstractController
......@@ -247,11 +246,9 @@ class UserController extends AbstractController
* @Route("/encaissement", name="encaissement")
* @IsGranted({"ROLE_CAISSIER", "ROLE_PRESTATAIRE"})
*/
public function encaissementAction(Request $request, UserPasswordEncoderInterface $encoder)
public function encaissementAction(Request $request)
{
$options = [];
$form = $this->createForm(EncaissementFormType::class, null, $options);
$form = $this->createForm(EncaissementFormType::class, null, []);
$form->handleRequest($request);
$validation = false;
......@@ -260,7 +257,7 @@ class UserController extends AbstractController
if ($form->isValid()) {
$input_code = $data["payment_code"];
$validation = true; // As soon as the form is valid, we're in validation
$validation = true; // As soon as the form is submitted & valid, we enter the validation process
if (empty($input_code)) {
// First step validated (set user & amount) -> go to validation
......@@ -281,7 +278,7 @@ class UserController extends AbstractController
}
// Check validation code
// TODO as we use password salt, must change payment code if password changes
// NOTE as we use password salt, must change payment code if password changes
$encoded_input = crypt($input_code, $adherent->getUser()->getSalt());
if (!hash_equals($adherent_code, $encoded_input)) {
$this->addFlash(
......
......@@ -56,7 +56,7 @@ class UserListener implements EventSubscriberInterface
public function onChangePasswordSuccess(FormEvent $event)
{
$url = $this->router->generate('index');
$url = $this->router->generate('index') . '?upswd=success';
$event->setResponse(new RedirectResponse($url));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment