I have the class User as the base class then i extended Teacher from user class.
When i try to login i get this error
You cannot refresh a user from the EntityUserProvider that does not contain an identifier. The user object has to be serialized with its own identifier mapped by Doctrine.
I have serialize/deserialize function in user.php as i have coped that from FOSUserbundle
public function serialize()
{
return serialize(array(
$this->password,
$this->salt,
$this->usernameCanonical,
$this->username,
$this->expired,
$this->locked,
$this->credentialsExpired,
$this->enabled,
));
}
I am not able to find where i can check for error. i am stuck. please help
"You cannot refresh a user from the EntityUserProvider that does not contain an identifier. The user object has to be serialized with its own identifier mapped by Doctrine."
This is not the answer to the question, but if someone googles the error message above (like I did) this is the top hit. And since I found my solution, I thought I'd share.
You will get this error if you remove the current user from the database and then try to redirect the user. (Which might seem like a silly mistake, but the error message sure isn't helping!) The solution is to simply clear out the session before you redirect.
$this->get('security.context')->setToken(null);
$this->get('request')->getSession()->invalidate();
From the code of EntityUserProvider.php
it seems that you have to serialize id
of the user also.
Just had the same issue using class table inheritance, it was caused by the visibility on the id
property set to private
, so the child class could not access the id, changing this to protected
solved it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With