Commit 1fad7504 authored by Mat's avatar Mat

encryptage du password + résolution erreur du login-check

parent 106fd4c2
...@@ -6,7 +6,7 @@ socket: ...@@ -6,7 +6,7 @@ socket:
logout: logout:
path: /logout path: /logout
login_check: login-check:
path: /login-check path: /login-check
### ###
......
...@@ -34,7 +34,7 @@ security: ...@@ -34,7 +34,7 @@ security:
form_login: form_login:
login_path: login login_path: login
check_path: login-check # une route ou un chemin check_path: login-check # une route ou un chemin
default_target_path: /chat default_target_path: chat_message
# ce sera souvent la page d'accueil # ce sera souvent la page d'accueil
always_use_default_target_path: true always_use_default_target_path: true
logout: logout:
......
...@@ -7,6 +7,7 @@ use SocketBundle\Form\UserType; ...@@ -7,6 +7,7 @@ use SocketBundle\Form\UserType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class ChatController extends Controller class ChatController extends Controller
...@@ -45,7 +46,7 @@ class ChatController extends Controller ...@@ -45,7 +46,7 @@ class ChatController extends Controller
* @Route(name="register", path="/register") * @Route(name="register", path="/register")
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function registerAction(Request $request) public function registerAction(Request $request, UserPasswordEncoderInterface $encoder)
{ {
$user = new User(); $user = new User();
...@@ -56,6 +57,9 @@ class ChatController extends Controller ...@@ -56,6 +57,9 @@ class ChatController extends Controller
{ {
$user->setRole(["ROLE_USER"]); // on affecte un rôle $user->setRole(["ROLE_USER"]); // on affecte un rôle
$pwd = $encoder->encodePassword($user, $user->getPassword());
$user->setPassword($pwd);
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$em->persist($user); $em->persist($user);
$em->flush(); $em->flush();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</head> </head>
<body> <body>
<form action="{{ path('login_check') }}" method="post"> <form action="{{ path('login-check') }}" method="post">
{% if error != null %} {% if error != null %}
{{ error.message }} {{ error.message }}
......
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