当我以管理员身份切换到用户时site.loc/?_switch_user=user@email.com
,我没有获得角色ROLE_PREVIOUS_ADMIN
。我不确定我应该向您展示哪个代码..
Symfony 版本:symfony2 2.2.2
用户.php
/**
* @see \Serializable::serialize()
*/
public function serialize()
{
return serialize(array(
$this->email
));
}
/**
* @see \Serializable::unserialize()
*/
public function unserialize($serialized)
{
list (
$this->email
) = unserialize($serialized);
}
public function isAccountNonExpired()
{
return true;
}
public function isAccountNonLocked()
{
return true;
}
public function isCredentialsNonExpired()
{
return true;
}
public function isEnabled()
{
return $this->isActive;
}
/**
* @inheritDoc
*/
public function eraseCredentials()
{
}
public function isEqualTo(UserInterface $user)
{
return
md5($user->getUsername()) == md5($this->getUsername()) &&
md5(serialize($user->getGroups())) == md5(serialize($this->getGroups()));
}