I am learning Symfony2 and I love it!
I have been using the great book and cookbook, but I can't find an answer to my question anywhere.
I am using another 3rd party login API, but it is a little slow to respond, so I would like to store known users in my own DB for faster respond time.
I have managed to create my own database with an entity provider and it works.
Now I would like to have Symfony try a login with my other service, when a login fails.
This is where, I would find it logical to put my new code.
public function loadUserByUsername($username) {
$q = $this
->createQueryBuilder('u')
->where('u.username = :username')
->setParameter('username', $username)
->getQuery();
try {
$user = $q->getSingleResult();
} catch (NoResultException $e) {
// Try login to other service before failing
$login = $APIHelper->login($username, $password);
if ($login) {
// Make sure the user is persisted to database
...
// Return the user
return $login->getUser();
}
else {
$message = sprintf(
'Unable to find user SHSnaphackBundle:User object identified by "%s".', $username
);
throw new UsernameNotFoundException($message, 0, $e);
}
}
return $user;
}
I would think, this would work perfectly, but can't find any way to get the password, the user tried to login with?
And is this the right file at all for this purpose?