X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=skyquake%2Fframework%2Fwidgets%2Fskyquake_rbac%2FskyquakeRBAC.jsx;h=0245e235e0c81c13c53650fb9b4652a97ebb6f2c;hb=119e39d96483d5cec756be95cc0cb735fb6f9a74;hp=cbb6a567ff2ac48293245ac6f8abc98efb9a0793;hpb=96b7649b2db9ab306a20b43db5f77b6111d746ed;p=osm%2FUI.git diff --git a/skyquake/framework/widgets/skyquake_rbac/skyquakeRBAC.jsx b/skyquake/framework/widgets/skyquake_rbac/skyquakeRBAC.jsx index cbb6a567f..0245e235e 100644 --- a/skyquake/framework/widgets/skyquake_rbac/skyquakeRBAC.jsx +++ b/skyquake/framework/widgets/skyquake_rbac/skyquakeRBAC.jsx @@ -21,6 +21,25 @@ import React from 'react'; import ROLES from 'utils/roleConstants.js'; const PLATFORM = ROLES.PLATFORM; +export function isRBACValid(User, allow){ + const UserData = User.data; + if(UserData) { + const PlatformRole = UserData.platform.role; + const isPlatformSuper = PlatformRole[PLATFORM.SUPER]; + const isPlatformAdmin = PlatformRole[PLATFORM.ADMIN]; + const isPlatformOper = PlatformRole[PLATFORM.OPER]; + const hasRoleAccess = checkForRoleAccess(UserData.project[User.projectId], PlatformRole, allow)//false//(this.props.roles.indexOf(userProfile.projectRole) > -1) + if (isPlatformSuper) { + return true; + } else { + if (hasRoleAccess) { + return true; + } + } + } + return false; +} + export default class SkyquakeRBAC extends React.Component { constructor(props, context) { super(props); @@ -30,19 +49,8 @@ export default class SkyquakeRBAC extends React.Component { const UserData = User.data; let HTML = null; // If user object has platform property then it has been populated by the back end. - if(UserData) { - const PlatformRole = UserData.platform.role; - const isPlatformSuper = PlatformRole[PLATFORM.SUPER]; - const isPlatformAdmin = PlatformRole[PLATFORM.ADMIN]; - const isPlatformOper = PlatformRole[PLATFORM.OPER]; - const hasRoleAccess = checkForRoleAccess(UserData.project[User.projectId], PlatformRole, this.props.allow)//false//(this.props.roles.indexOf(userProfile.projectRole) > -1) - if (isPlatformSuper) { - HTML = this.props.children; - } else { - if (hasRoleAccess) { - HTML = this.props.children; - } - } + if(isRBACValid(User, this.props.allow)) { + HTML = this.props.children; } return (
{HTML}
) }