Commit c3bcb1e9 authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Correction de bug

parent ab04aec4
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace UnicaenAuth\Assertion; namespace UnicaenAuth\Assertion;
use BjyAuthorize\Service\Authorize;
use UnicaenAuth\Service\Traits\UserContextServiceAwareTrait;
use Zend\Mvc\Application; use Zend\Mvc\Application;
use Zend\Mvc\MvcEvent; use Zend\Mvc\MvcEvent;
use Zend\Permissions\Acl\Acl; use Zend\Permissions\Acl\Acl;
...@@ -19,6 +21,7 @@ use Zend\ServiceManager\ServiceLocatorAwareTrait; ...@@ -19,6 +21,7 @@ use Zend\ServiceManager\ServiceLocatorAwareTrait;
abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAwareInterface abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAwareInterface
{ {
use ServiceLocatorAwareTrait; use ServiceLocatorAwareTrait;
use UserContextServiceAwareTrait;
/** /**
* @var Acl * @var Acl
...@@ -28,7 +31,7 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw ...@@ -28,7 +31,7 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
/** /**
* @var RoleInterface * @var RoleInterface
*/ */
private $role; private $role = false;
...@@ -94,6 +97,9 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw ...@@ -94,6 +97,9 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
*/ */
public function getAcl() public function getAcl()
{ {
if (!$this->acl){
$this->acl = $this->getServiceAuthorize()->getAcl();
}
return $this->acl; return $this->acl;
} }
...@@ -118,6 +124,12 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw ...@@ -118,6 +124,12 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
*/ */
public function getRole() public function getRole()
{ {
if (false === $this->role){
$sUserContext = $this->getServiceUserContext();
if ($sUserContext->getIdentity()) {
$this->role = $sUserContext->getSelectedIdentityRole();
}
}
return $this->role; return $this->role;
} }
...@@ -244,4 +256,17 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw ...@@ -244,4 +256,17 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
return $application->getMvcEvent(); return $application->getMvcEvent();
} }
/**
* @return Authorize
*/
private function getServiceAuthorize()
{
$serviceAuthorize = $this->getServiceLocator()->get('BjyAuthorize\Service\Authorize');
/* @var $serviceAuthorize Authorize */
return $serviceAuthorize;
}
} }
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace UnicaenAuth\Service\Traits; namespace UnicaenAuth\Service\Traits;
use UnicaenAuth\Service\UserContextService; use UnicaenAuth\Service\UserContext;
use RuntimeException; use RuntimeException;
/** /**
...@@ -13,18 +13,18 @@ use RuntimeException; ...@@ -13,18 +13,18 @@ use RuntimeException;
trait UserContextServiceAwareTrait trait UserContextServiceAwareTrait
{ {
/** /**
* @var UserContextService * @var UserContext
*/ */
private $serviceUserContext; private $serviceUserContext;
/** /**
* @param UserContextService $serviceUserContext * @param UserContext $serviceUserContext
* *
* @return self * @return self
*/ */
public function setServiceUserContext(UserContextService $serviceUserContext) public function setServiceUserContext(UserContext $serviceUserContext)
{ {
$this->serviceUserContext = $serviceUserContext; $this->serviceUserContext = $serviceUserContext;
...@@ -34,7 +34,7 @@ trait UserContextServiceAwareTrait ...@@ -34,7 +34,7 @@ trait UserContextServiceAwareTrait
/** /**
* @return UserContextService * @return UserContext
* @throws RuntimeException * @throws RuntimeException
*/ */
public function getServiceUserContext() public function getServiceUserContext()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment