Réglage en cours de l'affichage du user connecté
This commit is contained in:
parent
85d55df6fe
commit
55c85b29b8
|
@ -8,4 +8,4 @@ public/uploads/*
|
||||||
vendor
|
vendor
|
||||||
composer.json
|
composer.json
|
||||||
composer.lock
|
composer.lock
|
||||||
/src/Framework/SwiftMailerFactory.php
|
src/Framework/SwiftMailerFactory.php
|
||||||
|
|
|
@ -48,6 +48,6 @@ return [
|
||||||
},
|
},
|
||||||
// MAILER
|
// MAILER
|
||||||
'mail.to' => 'admin@gmarche-testmail.com',
|
'mail.to' => 'admin@gmarche-testmail.com',
|
||||||
'mail.from' => '$mail_from',
|
'mail.from' => "$mail_from",
|
||||||
Swift_Mailer::class => \DI\factory(\Framework\SwiftMailerFactory::class)
|
Swift_Mailer::class => \DI\factory(\Framework\SwiftMailerFactory::class)
|
||||||
];
|
];
|
||||||
|
|
|
@ -5,7 +5,7 @@ include '../../config/config.php';
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password);
|
$bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password);
|
||||||
if (isset($_POST['nom_connecte']) && isset($_POST['mdp']) != "") {
|
if (isset($_POST['nom_connecte']) && isset($_POST['mdp'])) {
|
||||||
|
|
||||||
$params["username"] = $_POST['nom_connecte'];
|
$params["username"] = $_POST['nom_connecte'];
|
||||||
$requete = "SELECT username, password
|
$requete = "SELECT username, password
|
||||||
|
|
|
@ -25,14 +25,15 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="mot_de_passe" class="col-sm-10 card" style="text-align: left;margin-top:0.8rem; margin-left: 1.7rem;">
|
<div id="mot_de_passe" class="col-sm-10 card" style="text-align: left;margin-top:0.8rem; margin-left: 1.7rem;">
|
||||||
<div class="card-block" style="margin-left: 1rem;">
|
<div class="card-block" style="margin-left: 1rem;margin-top:0.6rem;">
|
||||||
<h5 class="card-title">Changement de mot de passe</h5>
|
<h5 class="card-title">Changement de mot de passe</h5>
|
||||||
|
<h5 class="card-title">(via l'envoi d'un lien par mail)</h5>
|
||||||
<div class="container" style="background-color: lightgray;opacity: 0.9;
|
<div class="container" style="background-color: lightgray;opacity: 0.9;
|
||||||
margin-left: 0rem;margin-bottom:1rem; padding:1rem;">
|
margin-left: 0rem;margin-bottom:1rem; padding:1rem;">
|
||||||
<form action="" method="post">
|
<form action="/password" method="post">
|
||||||
{{ csrf_input() }}
|
{{ csrf_input() }}
|
||||||
{{ field('email', email, 'Email', {type: 'email'}) }}
|
{{ field('email', email, 'Votre Email', {type: 'email'}) }}
|
||||||
<button class="btn btn-primary">Envoyer lien de reset du mot de passe</button>
|
<button class="btn btn-primary">Changer de mot de passe</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,12 +3,15 @@ namespace App\Auth\Action;
|
||||||
|
|
||||||
use App\Auth\Mailer\PasswordResetMailer;
|
use App\Auth\Mailer\PasswordResetMailer;
|
||||||
use App\Auth\UserTable;
|
use App\Auth\UserTable;
|
||||||
|
use Framework\Actions\RouterAwareAction;
|
||||||
use Framework\Database\NoRecordException;
|
use Framework\Database\NoRecordException;
|
||||||
use Framework\Renderer\RendererInterface;
|
use Framework\Renderer\RendererInterface;
|
||||||
use Framework\Response\RedirectResponse;
|
use Framework\Response\RedirectResponse;
|
||||||
|
use Framework\Router;
|
||||||
use Framework\Session\FlashService;
|
use Framework\Session\FlashService;
|
||||||
use Framework\Validator;
|
use Framework\Validator;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Zend\Expressive\Router\RouterInterface;
|
||||||
|
|
||||||
class PasswordForgetAction
|
class PasswordForgetAction
|
||||||
{
|
{
|
||||||
|
@ -17,6 +20,10 @@ class PasswordForgetAction
|
||||||
* @var RendererInterface
|
* @var RendererInterface
|
||||||
*/
|
*/
|
||||||
private $renderer;
|
private $renderer;
|
||||||
|
/**
|
||||||
|
* @var RouterInterface
|
||||||
|
*/
|
||||||
|
private $router;
|
||||||
/**
|
/**
|
||||||
* @var UserTable
|
* @var UserTable
|
||||||
*/
|
*/
|
||||||
|
@ -30,14 +37,17 @@ class PasswordForgetAction
|
||||||
*/
|
*/
|
||||||
private $flashService;
|
private $flashService;
|
||||||
|
|
||||||
|
use RouterAwareAction;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
RendererInterface $renderer,
|
RendererInterface $renderer,
|
||||||
|
Router $router,
|
||||||
UserTable $userTable,
|
UserTable $userTable,
|
||||||
PasswordResetMailer $mailer,
|
PasswordResetMailer $mailer,
|
||||||
FlashService $flashService
|
FlashService $flashService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$this->renderer = $renderer;
|
$this->renderer = $renderer;
|
||||||
|
$this->router = $router;
|
||||||
$this->userTable = $userTable;
|
$this->userTable = $userTable;
|
||||||
$this->mailer = $mailer;
|
$this->mailer = $mailer;
|
||||||
$this->flashService = $flashService;
|
$this->flashService = $flashService;
|
||||||
|
@ -45,9 +55,10 @@ class PasswordForgetAction
|
||||||
|
|
||||||
public function __invoke(ServerRequestInterface $request)
|
public function __invoke(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
/*if ($request->getMethod() === 'GET') {
|
if ($request->getMethod() === 'GET') {
|
||||||
return $this->renderer->render('@auth/password');
|
$affichage_div = true;
|
||||||
}*/
|
return $this->renderer->render('@auth/password',compact('affichage_div'));
|
||||||
|
}
|
||||||
$params = $request->getParsedBody();
|
$params = $request->getParsedBody();
|
||||||
$validator = (new Validator($params))
|
$validator = (new Validator($params))
|
||||||
->notEmpty('email')
|
->notEmpty('email')
|
||||||
|
@ -61,13 +72,21 @@ class PasswordForgetAction
|
||||||
'token' => $token
|
'token' => $token
|
||||||
]);
|
]);
|
||||||
$this->flashService->success('Un email vous a été envoyé');
|
$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) {
|
} 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 {
|
} else {
|
||||||
$errors = $validator->getErrors();
|
$errors = $validator->getErrors();
|
||||||
}
|
}
|
||||||
return $this->renderer->render('@auth/password', compact('errors'));
|
$affichage_div = true;
|
||||||
|
return $this->renderer->render('@auth/password', compact('errors','affichage_div'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,25 @@
|
||||||
{% extends 'layout.twig' %}
|
{% extends 'layout.twig' %}
|
||||||
|
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
|
{% if flash('error') %}
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
{{ flash('error') }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<!-- if flash('success') %}
|
||||||
|
<div class="alert alert-success">
|
||||||
|
flash('success')
|
||||||
|
</div>
|
||||||
|
endif -->
|
||||||
|
|
||||||
{% if flash('error') %}
|
{% if affichage_div %}
|
||||||
<div class="alert alert-danger">
|
<div id="password" class="container" style="background-color: lightgray;opacity: 0.9;margin: 1rem;padding:1rem;">
|
||||||
{{ flash('error') }}
|
<form action="" method="post">
|
||||||
</div>
|
<!-- csrf_input() -->
|
||||||
{% endif %}
|
{{ field('email', null, 'Votre Email', {type: 'email'}) }}
|
||||||
<!-- if flash('success') %}
|
<button class="btn btn-primary">Réinitialiser mon mot de passe</button>
|
||||||
<div class="alert alert-success">
|
</form>
|
||||||
flash('success')
|
</div>
|
||||||
</div>
|
{% endif %}
|
||||||
endif -->
|
|
||||||
<div class="container" style="background-color: lightgray;opacity: 0.9;margin: 1rem;padding:1rem;">
|
|
||||||
<form action="" method="post">
|
|
||||||
{{ csrf_input() }}
|
|
||||||
{{ field('email', null, 'Email', {type: 'email'}) }}
|
|
||||||
<button class="btn btn-primary">Réinitialiser mon mot de passe</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -9,7 +9,8 @@ class SwiftMailerFactory
|
||||||
public function __invoke(ContainerInterface $container): \Swift_Mailer
|
public function __invoke(ContainerInterface $container): \Swift_Mailer
|
||||||
{
|
{
|
||||||
if ($container->get('env') === 'production') {
|
if ($container->get('env') === 'production') {
|
||||||
$transport = new \Swift_SendmailTransport();
|
//$transport = new \Swift_SendmailTransport();
|
||||||
|
$transport = new \Swift_SmtpTransport('localhost', 1025);
|
||||||
} else {
|
} else {
|
||||||
$transport = new \Swift_SmtpTransport('localhost', 1025);
|
$transport = new \Swift_SmtpTransport('localhost', 1025);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@
|
||||||
{{ "now"|date('d/m/y') }}
|
{{ "now"|date('d/m/y') }}
|
||||||
</div>
|
</div>
|
||||||
{% if nom_user != '' %}
|
{% if nom_user != '' %}
|
||||||
<!-- <button style="background-color: transparent;padding:0;border:0;" -->
|
|
||||||
<form method="post" style="margin-top:5px;" action="{{ path('account.profil') }}">
|
<form method="post" style="margin-top:5px;" action="{{ path('account.profil') }}">
|
||||||
<span><img src="\avatar_user.png" width="22" height="22" /></span>
|
<span><img src="\avatar_user.png" width="22" height="22" /></span>
|
||||||
<!--<span id="nom_connecte"> nom_user </span>-->
|
<!--<span id="nom_connecte"> nom_user </span>-->
|
||||||
|
@ -69,8 +68,8 @@
|
||||||
<div class="nav-item" id="bouton-connexion">
|
<div class="nav-item" id="bouton-connexion">
|
||||||
<button style="color:white; font-size: 14px;" class="btn btn-primary" data-toggle="modal" data-target="#connexion_modal">Se connecter</button>
|
<button style="color:white; font-size: 14px;" class="btn btn-primary" data-toggle="modal" data-target="#connexion_modal">Se connecter</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="nom_connecte" style="display:none;margin-left:10px;margin-top:6px;margin-right:8px;">
|
<!-- <div id="nom_connecte" style="display:none;margin-left:10px;margin-top:6px;margin-right:8px;">
|
||||||
</div>
|
</div>-->
|
||||||
<div id="deconnexion" style="display:none;">
|
<div id="deconnexion" style="display:none;">
|
||||||
<form method="post" action="{{ path('auth.logout') }}">
|
<form method="post" action="{{ path('auth.logout') }}">
|
||||||
<!-- csrf_input() }}-->
|
<!-- csrf_input() }}-->
|
||||||
|
|
Loading…
Reference in New Issue