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
|
||||
composer.json
|
||||
composer.lock
|
||||
/src/Framework/SwiftMailerFactory.php
|
||||
src/Framework/SwiftMailerFactory.php
|
||||
|
|
|
@ -48,6 +48,6 @@ return [
|
|||
},
|
||||
// MAILER
|
||||
'mail.to' => 'admin@gmarche-testmail.com',
|
||||
'mail.from' => '$mail_from',
|
||||
'mail.from' => "$mail_from",
|
||||
Swift_Mailer::class => \DI\factory(\Framework\SwiftMailerFactory::class)
|
||||
];
|
||||
|
|
|
@ -5,7 +5,7 @@ include '../../config/config.php';
|
|||
try {
|
||||
|
||||
$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'];
|
||||
$requete = "SELECT username, password
|
||||
|
|
|
@ -25,14 +25,15 @@
|
|||
</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 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">(via l'envoi d'un lien par mail)</h5>
|
||||
<div class="container" style="background-color: lightgray;opacity: 0.9;
|
||||
margin-left: 0rem;margin-bottom:1rem; padding:1rem;">
|
||||
<form action="" method="post">
|
||||
<form action="/password" method="post">
|
||||
{{ csrf_input() }}
|
||||
{{ field('email', email, 'Email', {type: 'email'}) }}
|
||||
<button class="btn btn-primary">Envoyer lien de reset du mot de passe</button>
|
||||
{{ field('email', email, 'Votre Email', {type: 'email'}) }}
|
||||
<button class="btn btn-primary">Changer de mot de passe</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,25 @@
|
|||
{% extends 'layout.twig' %}
|
||||
|
||||
|
||||
{% 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') %}
|
||||
<div class="alert alert-danger">
|
||||
{{ flash('error') }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<!-- if flash('success') %}
|
||||
<div class="alert alert-success">
|
||||
flash('success')
|
||||
</div>
|
||||
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>
|
||||
{% if affichage_div %}
|
||||
<div id="password" class="container" style="background-color: lightgray;opacity: 0.9;margin: 1rem;padding:1rem;">
|
||||
<form action="" method="post">
|
||||
<!-- csrf_input() -->
|
||||
{{ field('email', null, 'Votre Email', {type: 'email'}) }}
|
||||
<button class="btn btn-primary">Réinitialiser mon mot de passe</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
{{ "now"|date('d/m/y') }}
|
||||
</div>
|
||||
{% if nom_user != '' %}
|
||||
<!-- <button style="background-color: transparent;padding:0;border:0;" -->
|
||||
<form method="post" style="margin-top:5px;" action="{{ path('account.profil') }}">
|
||||
<span><img src="\avatar_user.png" width="22" height="22" /></span>
|
||||
<!--<span id="nom_connecte"> nom_user </span>-->
|
||||
|
@ -69,8 +68,8 @@
|
|||
<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>
|
||||
</div>
|
||||
<div id="nom_connecte" style="display:none;margin-left:10px;margin-top:6px;margin-right:8px;">
|
||||
</div>
|
||||
<!-- <div id="nom_connecte" style="display:none;margin-left:10px;margin-top:6px;margin-right:8px;">
|
||||
</div>-->
|
||||
<div id="deconnexion" style="display:none;">
|
||||
<form method="post" action="{{ path('auth.logout') }}">
|
||||
<!-- csrf_input() }}-->
|
||||
|
|
Loading…
Reference in New Issue