Created
September 4, 2011 14:54
-
-
Save stof/1192957 to your computer and use it in GitHub Desktop.
Logging in by email or username with FOSUserBundle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fos_user: | |
# ... | |
service: | |
user_manager: my_user_manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
my_user_manager: | |
class: Acme\UserBundle\Model\UserManager | |
parent: fos_user.user_manager.default | |
public: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acme\UserBundle\Model; | |
use FOS\UserBundle\Entity\UserManager as BaseUserManager; | |
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; | |
class UserManager extends BaseUserManager | |
{ | |
public function loadUserByUsername($username) | |
{ | |
$user = $this->findUserByUsernameOrEmail($username); | |
if (!$user) { | |
throw new UsernameNotFoundException(sprintf('No user with name "%s" was found.', $username)); | |
} | |
return $user; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment