nette/nette — Issue #444: Nette\Http\User::isInRole
Author: Werkov
Created: 2012-01-01 14:37:49+00:00
State: open

In the case of own implementation of IIdentity and IRole, this method doesn't work correctly. Correct behavior would yield the following reimplementation:

/**
* Is a user in the specified effective role?
* @param string
* @return bool
*/
final public function isInRole($role) {
return in_array($role, array_map(function($role) {
if ($role instanceof \Nette\Security\IRole)
return $role->getRoleId();
else
return $role;
}, $this->getRoles()), TRUE);
}