Created
May 19, 2012 06:01
-
-
Save coreymcmahon/2729515 to your computer and use it in GitHub Desktop.
Using a custom UserInterface for Symfony Security - http://www.symfonycentral.com/securing-your-web-application-with-symfony.html
This file contains hidden or 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 MyCompany\BlogBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
// Add this so that we load the UserInterface class | |
use Symfony\Component\Security\Core\User\UserInterface; | |
class User implements UserInterface // Make sure we implement UserInterface | |
{ | |
/* Auto-generated code... */ | |
function getRoles() | |
{ | |
// We aren't going to use roles for this demonstration. | |
return array(); | |
} | |
function eraseCredentials() | |
{ | |
// We're going to be using hashed passwords, so we don't have to do anything here. | |
return; | |
} | |
function equals(UserInterface $user) | |
{ | |
// We're going to use 'username' as the primary identifier, so let's use that for comparison... | |
return $this->getUsername() == $user->getUsername(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment