I have a question about the FOSUserBundle for Symfony 2.0.x. In there documentation you can find a way to change the login to work with either username and email. That works great! But I want to login to work with just the email. So I added a function in my CustomUserManager (extends from the original) that makes sure you just can logon with your email.
namespace Frontend\UserBundle\Model;
use FOS\UserBundle\Entity\UserManager;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
class CustomUserManager extends UserManager
{
public function loadUserByUsername($email)
{
/*$user = $this->findUserByUsernameOrEmail($username);
if (!$user) {
throw new UsernameNotFoundException(sprintf('No user with name "%s" was found.', $username));
}
return $user;*/
//Change it to only email (Default calls loadUserByUsername -> we send it to our own loadUserByEmail)
return $this->loadUserByEmail($email);
}
public function loadUserByEmail($email)
{
$user = $this->findUserByEmail($email);
if (!$user) {
throw new UsernameNotFoundException(sprintf('No user with email "%s" was found.', $email));
}
return $user;
}
}
But now I have a problem that I need to control the values that are saved in the session. He saves my username in the session and when the system checks this there will be no email (Because he only checks on email) available.
So my question is how/where can you change the value that is stored inside the username variable.
Thanks!