Skip to content
Advertisement

symfony – getting logged out at form->handleRequest

I have a problem regarding my Symfony4 App.

What is happening?

I want to build a “Change Password” function for the currently logged in user. So far everything is fine imo. When I submit the form everything seems to have worked fine (redirect to correct page, page is displayed, .. ). But when I want to navigate to another page I get redirected to my login page due to no authentication. There I found out, that the password was not changed either.

I am very thankful for any kind of help!

EDIT

The log out is happening any time the form is submitted, regardles of errors or not.

Controller

JavaScript

Form Type

JavaScript

Twig

JavaScript

Advertisement

Answer

Just to post a workaround if anyone having the same problem. Just like Jakumi mentioned, I was mapping the password of the user object. Somehow, while validating this by symfony the User gets logged out.

What worked was removing the user object from the form, so here are a few updated snippets:

Controller creating form

JavaScript

Form Type configureOptions

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement