Archived
1
0
Fork 0

app/listeners/AccessListener.php: fetch role from identity.

This commit is contained in:
Henrik Hautakoski 2018-10-04 09:46:00 +02:00
parent 388b5933cb
commit f276ad92a8
No known key found for this signature in database
GPG key ID: 839F3A7EAFAEAFAA

View file

@ -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;
} }