isActive = true; // may not be needed, see section on salt below // $this->salt = md5(uniqid('', true)); } public function getUsername() { return $this->username; } public function getSalt() { // you *may* need a real salt depending on your encoder // see section on salt below return null; } public function getPassword() { return $this->password; } public function getRoles() { return array('ROLE_USER'); } public function eraseCredentials() { } /** @see \Serializable::serialize() */ public function serialize() { return serialize(array( $this->id, $this->username, $this->password, // see section on salt below // $this->salt, )); } /** @see \Serializable::unserialize() */ public function unserialize($serialized) { list ( $this->id, $this->username, $this->password, // see section on salt below // $this->salt ) = unserialize($serialized, array('allowed_classes' => false)); } }