Merge pull request #144 from havvg/master
fix SecurityIdentity username with multiple dashes
This commit is contained in:
commit
3f4be39a9d
|
@ -34,7 +34,7 @@ class SecurityIdentity extends BaseSecurityIdentity
|
|||
throw new \InvalidArgumentException('The given identifier does not resolve to a UserSecurityIdentity.');
|
||||
}
|
||||
|
||||
list($class, $username) = explode('-', $identifier);
|
||||
list($class, $username) = explode('-', $identifier, 2);
|
||||
|
||||
return new UserSecurityIdentity($username, $class);
|
||||
}
|
||||
|
|
|
@ -54,6 +54,17 @@ class SecurityIdentityTest extends AclTestCase
|
|||
$this->assertInstanceOf('Symfony\Component\Security\Acl\Domain\UserSecurityIdentity', $secIdentity);
|
||||
}
|
||||
|
||||
public function testToAclIdentityMultipleDashes()
|
||||
{
|
||||
$identity = new SecurityIdentity();
|
||||
$identity->setIdentifier('Propel\PropelBundle\Tests\Fixtures\UserProxy-some-username@domain.com');
|
||||
$identity->setUsername(true);
|
||||
|
||||
$secIdentity = SecurityIdentity::toAclIdentity($identity);
|
||||
$this->assertInstanceOf('Symfony\Component\Security\Acl\Domain\UserSecurityIdentity', $secIdentity);
|
||||
$this->assertEquals('some-username@domain.com', $secIdentity->getUsername());
|
||||
}
|
||||
|
||||
public function testToAclIdentityValidRole()
|
||||
{
|
||||
$identity = new SecurityIdentity();
|
||||
|
@ -108,4 +119,4 @@ class SecurityIdentityTest extends AclTestCase
|
|||
$dbEntry = SecurityIdentityQuery::create()->findPk($identity->getId());
|
||||
$this->assertInstanceOf('Propel\PropelBundle\Model\Acl\SecurityIdentity', $dbEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue