Programmatically logging in the user through:
$user = new CustomEntityUser();
$user->setUsername("foo");
$user->setPassword("bar");
$entityManager->persist($user);
$entityManager->flush();
$token = new UsernamePasswordToken($user, $user->getPassword(), "main", $user->getRoles());
$this->get('security.token_storage')->setToken($token);
doesn't authenticate the user properly. The debug bar goes yellow and says: "Authenticated No". The name of the firewall is main
.
The user-entity-class has implemented the Serializeable
-interface according to documentation.