javascript - FOSUserBundle AJAX Login with Symfony2 (routing)
Get the solution ↓↓↓Solution:
First Issue: You are sending an invalid CSRF token. In Symfony 2.3 you could generate it using{{ csrf_token('authenticate') }}
inside the template'sinput
'svalue
.
Second issue: Do not overwrite the route, simply use the original route:fos_user_security_check
.
In general: if you use anAuthenticationSuccessHandler
extendingSymfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler
your method could look something like this:
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
if ($request->isXmlHttpRequest()) {
return new JsonResponse(array('success' => true));
}
return parent::onAuthenticationSuccess($request, $token);
}
Do something similar for anAuthenticationFailureHandler
extendingSymfony\Component\Security\Http\Authentication\DefaultAuthenticationFailureHandler
.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.