+
Changement de mot de passe
+
(via l'envoi d'un lien par mail)
-
diff --git a/src/Auth/Action/PasswordForgetAction.php b/src/Auth/Action/PasswordForgetAction.php
index 0d95584..b354c59 100644
--- a/src/Auth/Action/PasswordForgetAction.php
+++ b/src/Auth/Action/PasswordForgetAction.php
@@ -3,12 +3,15 @@ namespace App\Auth\Action;
use App\Auth\Mailer\PasswordResetMailer;
use App\Auth\UserTable;
+use Framework\Actions\RouterAwareAction;
use Framework\Database\NoRecordException;
use Framework\Renderer\RendererInterface;
use Framework\Response\RedirectResponse;
+use Framework\Router;
use Framework\Session\FlashService;
use Framework\Validator;
use Psr\Http\Message\ServerRequestInterface;
+use Zend\Expressive\Router\RouterInterface;
class PasswordForgetAction
{
@@ -17,6 +20,10 @@ class PasswordForgetAction
* @var RendererInterface
*/
private $renderer;
+ /**
+ * @var RouterInterface
+ */
+ private $router;
/**
* @var UserTable
*/
@@ -30,14 +37,17 @@ class PasswordForgetAction
*/
private $flashService;
+ use RouterAwareAction;
+
public function __construct(
RendererInterface $renderer,
+ Router $router,
UserTable $userTable,
PasswordResetMailer $mailer,
FlashService $flashService
) {
-
$this->renderer = $renderer;
+ $this->router = $router;
$this->userTable = $userTable;
$this->mailer = $mailer;
$this->flashService = $flashService;
@@ -45,9 +55,10 @@ class PasswordForgetAction
public function __invoke(ServerRequestInterface $request)
{
- /*if ($request->getMethod() === 'GET') {
- return $this->renderer->render('@auth/password');
- }*/
+ if ($request->getMethod() === 'GET') {
+ $affichage_div = true;
+ return $this->renderer->render('@auth/password',compact('affichage_div'));
+ }
$params = $request->getParsedBody();
$validator = (new Validator($params))
->notEmpty('email')
@@ -61,13 +72,21 @@ class PasswordForgetAction
'token' => $token
]);
$this->flashService->success('Un email vous a été envoyé');
- return new RedirectResponse($request->getUri()->getPath());
+ //return new RedirectResponse($request->getUri()->getPath());
+ //$path = $this->router->generateUri('account.profil');
+ //$this->session->delete('auth.redirect');
+
+ //return new RedirectResponse($path);
+ $affichage_div = false;
+ return $this->renderer->render('@auth/password',compact('affichage_div'));
} catch (NoRecordException $e) {
- $errors = ['email' => 'Aucun utilisateur ne correspond à cet email'];
+ //$errors = ['email' => 'Aucun utilisateur ne correspond à cet email'];
+ $this->flashService->error('Aucun utilisateur ne correspond à cet email');
}
} else {
$errors = $validator->getErrors();
}
- return $this->renderer->render('@auth/password', compact('errors'));
+ $affichage_div = true;
+ return $this->renderer->render('@auth/password', compact('errors','affichage_div'));
}
}
diff --git a/src/Auth/views/password.twig b/src/Auth/views/password.twig
index 66eebf5..808cfe4 100644
--- a/src/Auth/views/password.twig
+++ b/src/Auth/views/password.twig
@@ -1,24 +1,25 @@
{% extends 'layout.twig' %}
-
{% block body %}
+ {% if flash('error') %}
+
+ {{ flash('error') }}
+
+ {% endif %}
+
- {% if flash('error') %}
-
- {{ flash('error') }}
-
- {% endif %}
-
-
-
-
+ {% if affichage_div %}
+
+
+
+ {% endif %}
{% endblock %}
diff --git a/src/Framework/SwiftMailerFactory.php b/src/Framework/SwiftMailerFactory.php
index 9e2eb81..6c1dd55 100644
--- a/src/Framework/SwiftMailerFactory.php
+++ b/src/Framework/SwiftMailerFactory.php
@@ -9,7 +9,8 @@ class SwiftMailerFactory
public function __invoke(ContainerInterface $container): \Swift_Mailer
{
if ($container->get('env') === 'production') {
- $transport = new \Swift_SendmailTransport();
+ //$transport = new \Swift_SendmailTransport();
+ $transport = new \Swift_SmtpTransport('localhost', 1025);
} else {
$transport = new \Swift_SmtpTransport('localhost', 1025);
}
diff --git a/views/layout.twig b/views/layout.twig
index ff1805a..3cde16f 100644
--- a/views/layout.twig
+++ b/views/layout.twig
@@ -55,7 +55,6 @@
{{ "now"|date('d/m/y') }}
{% if nom_user != '' %}
-