Custom project roles inherit from project members

This commit is contained in:
Frederic Guillot
2016-09-08 20:44:03 -04:00
parent dded773749
commit fedf4ea2de
4 changed files with 86 additions and 0 deletions

View File

@@ -49,6 +49,18 @@ class Role
);
}
/**
* Check if the given role is custom or not
*
* @access public
* @param string $role
* @return bool
*/
public function isCustomProjectRole($role)
{
return ! empty($role) && $role !== self::PROJECT_MANAGER && $role !== self::PROJECT_MEMBER && $role !== self::PROJECT_VIEWER;
}
/**
* Get role name
*

View File

@@ -150,6 +150,11 @@ class UserHelper extends Base
if ($result === null) {
$role = $this->getProjectUserRole($project_id);
if ($this->role->isCustomProjectRole($role)) {
$role = Role::PROJECT_MEMBER;
}
$result = $this->projectAuthorization->isAllowed($controller, $action, $role);
$this->memoryCache->set($key, $result);
}