Commit 1fad7504 authored by Mat's avatar Mat

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

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