Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Created May 19, 2012 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coreymcmahon/2729515 to your computer and use it in GitHub Desktop.
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
<?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