app/listeners/AccessListener.php: fetch role from identity.
This commit is contained in:
parent
388b5933cb
commit
f276ad92a8
1 changed files with 6 additions and 3 deletions
|
|
@ -24,10 +24,13 @@ class AccessListener extends Plugin
|
||||||
*/
|
*/
|
||||||
public function beforeExecuteRoute(Event $event, Dispatcher $dispatcher) : bool
|
public function beforeExecuteRoute(Event $event, Dispatcher $dispatcher) : bool
|
||||||
{
|
{
|
||||||
// We only have two roles for now, authenticated users and guests.
|
// If we have an identity, fetch type from authed user.
|
||||||
if ($this->auth->hasIdentity()) {
|
if ($this->auth->hasIdentity()) {
|
||||||
$role = Acl::ROLE_USER;
|
$user = $this->auth->getUser();
|
||||||
} else {
|
$role = $user->getType();
|
||||||
|
}
|
||||||
|
// Othersize, we default to role.
|
||||||
|
else {
|
||||||
$role = Acl::ROLE_GUEST;
|
$role = Acl::ROLE_GUEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue