2019-03-14 23:41:04 -07:00
|
|
|
pragma solidity ^0.5.3;
|
|
|
|
|
|
|
|
import "./RoleManager.sol";
|
|
|
|
import "./AccountManager.sol";
|
|
|
|
import "./VoterManager.sol";
|
|
|
|
import "./NodeManager.sol";
|
|
|
|
import "./OrgManager.sol";
|
2019-03-15 02:26:57 -07:00
|
|
|
import "./PermissionsUpgradable.sol";
|
2019-03-14 23:41:04 -07:00
|
|
|
|
|
|
|
contract PermissionsImplementation {
|
|
|
|
AccountManager private accounts;
|
|
|
|
RoleManager private roles;
|
|
|
|
VoterManager private voter;
|
|
|
|
NodeManager private nodes;
|
|
|
|
OrgManager private org;
|
2019-03-19 02:15:51 -07:00
|
|
|
PermissionsUpgradable private permUpgradable;
|
|
|
|
|
2019-03-14 23:41:04 -07:00
|
|
|
string private adminOrg;
|
|
|
|
string private adminRole;
|
|
|
|
string private orgAdminRole;
|
|
|
|
|
2019-04-08 07:26:13 -07:00
|
|
|
|
2019-03-14 23:41:04 -07:00
|
|
|
uint private fullAccess = 3;
|
|
|
|
|
|
|
|
// checks if first time network boot up has happened or not
|
|
|
|
bool private networkBoot = false;
|
|
|
|
|
2019-03-15 02:26:57 -07:00
|
|
|
modifier onlyProxy
|
|
|
|
{
|
|
|
|
require(msg.sender == permUpgradable.getPermInterface(), "can be called by proxy only");
|
|
|
|
_;
|
|
|
|
}
|
2019-04-08 01:57:36 -07:00
|
|
|
// Modifiers
|
2019-03-14 23:41:04 -07:00
|
|
|
// Checks if the given network boot up is pending exists
|
2019-03-28 02:53:11 -07:00
|
|
|
modifier networkBootStatus(bool _status)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-03-28 02:53:11 -07:00
|
|
|
require(networkBoot == _status, "Incorrect network boot status");
|
2019-03-14 23:41:04 -07:00
|
|
|
_;
|
|
|
|
}
|
2019-05-10 00:17:01 -07:00
|
|
|
|
|
|
|
// checks if the account is a network admin
|
2019-03-14 23:41:04 -07:00
|
|
|
modifier networkAdmin(address _account) {
|
|
|
|
require(isNetworkAdmin(_account) == true, "Not an network admin");
|
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// checks if the account is a org admin
|
2019-03-14 23:41:04 -07:00
|
|
|
modifier orgAdmin(address _account, string memory _orgId) {
|
2019-04-04 03:25:43 -07:00
|
|
|
require(isOrgAdmin(_account, _orgId) == true, "Not an org admin");
|
2019-03-14 23:41:04 -07:00
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// checks if the org does not exists
|
2019-03-14 23:41:04 -07:00
|
|
|
modifier orgNotExists(string memory _orgId) {
|
2019-03-28 02:53:11 -07:00
|
|
|
require(checkOrgExists(_orgId) != true, "Org already exists");
|
2019-03-14 23:41:04 -07:00
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// checks if the org does exists
|
2019-03-14 23:41:04 -07:00
|
|
|
modifier orgExists(string memory _orgId) {
|
2019-03-28 02:53:11 -07:00
|
|
|
require(checkOrgExists(_orgId) == true, "Org does not exists");
|
2019-03-14 23:41:04 -07:00
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// checks if the org is approved
|
2019-03-14 23:41:04 -07:00
|
|
|
modifier orgApproved(string memory _orgId) {
|
2019-03-28 02:53:11 -07:00
|
|
|
require(checkOrgApproved(_orgId) == true, "Org not approved");
|
2019-03-14 23:41:04 -07:00
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// constructor. sets the upgradable address
|
2019-03-15 02:26:57 -07:00
|
|
|
constructor (address _permUpgradable) public {
|
2019-03-19 02:15:51 -07:00
|
|
|
permUpgradable = PermissionsUpgradable(_permUpgradable);
|
2019-03-15 02:26:57 -07:00
|
|
|
}
|
2019-03-14 23:41:04 -07:00
|
|
|
|
2019-04-08 01:57:36 -07:00
|
|
|
// initial set up related functions
|
|
|
|
// set policy related attributes
|
2019-03-14 23:41:04 -07:00
|
|
|
function setPolicy(string calldata _nwAdminOrg, string calldata _nwAdminRole, string calldata _oAdminRole) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-28 02:53:11 -07:00
|
|
|
networkBootStatus(false)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
|
|
|
adminOrg = _nwAdminOrg;
|
|
|
|
adminRole = _nwAdminRole;
|
|
|
|
orgAdminRole = _oAdminRole;
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// called at the time network initialization to link all the contracts and set defaults
|
2019-04-14 21:32:06 -07:00
|
|
|
function init(address _orgManager, address _rolesManager, address _acctManager, address _voterManager, address _nodeManager, uint _breadth, uint _depth) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-28 02:53:11 -07:00
|
|
|
networkBootStatus(false)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
|
|
|
org = OrgManager(_orgManager);
|
|
|
|
roles = RoleManager(_rolesManager);
|
|
|
|
accounts = AccountManager(_acctManager);
|
|
|
|
voter = VoterManager(_voterManager);
|
|
|
|
nodes = NodeManager(_nodeManager);
|
|
|
|
|
2019-04-14 21:32:06 -07:00
|
|
|
org.setUpOrg(adminOrg, _breadth, _depth);
|
2019-04-26 01:35:51 -07:00
|
|
|
roles.addRole(adminRole, adminOrg, fullAccess, true, true);
|
2019-03-14 23:41:04 -07:00
|
|
|
accounts.setDefaults(adminRole, orgAdminRole);
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// function to add admin node as a part of network boot up
|
2019-03-14 23:41:04 -07:00
|
|
|
function addAdminNodes(string calldata _enodeId) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-28 02:53:11 -07:00
|
|
|
networkBootStatus(false)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-03-28 02:53:11 -07:00
|
|
|
nodes.addAdminNode(_enodeId, adminOrg);
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// function to add admin accounts as a part of network boot up
|
2019-03-14 23:41:04 -07:00
|
|
|
function addAdminAccounts(address _acct) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-28 02:53:11 -07:00
|
|
|
networkBootStatus(false)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-03-28 02:53:11 -07:00
|
|
|
updateVoterList(adminOrg, _acct, true);
|
2019-04-23 23:40:28 -07:00
|
|
|
accounts.assignAdminRole(_acct, adminOrg, adminRole, 2);
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// update the network boot status as true
|
|
|
|
function updateNetworkBootStatus() external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-28 02:53:11 -07:00
|
|
|
networkBootStatus(false)
|
2019-03-14 23:41:04 -07:00
|
|
|
returns (bool)
|
|
|
|
{
|
|
|
|
networkBoot = true;
|
|
|
|
return networkBoot;
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// functions to add a new org to the network
|
2019-04-08 01:57:36 -07:00
|
|
|
function addOrg(string calldata _orgId, string calldata _enodeId, address _account, address _caller) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-28 02:53:11 -07:00
|
|
|
networkBootStatus(true)
|
2019-03-19 02:15:51 -07:00
|
|
|
networkAdmin(_caller)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-04-08 23:58:30 -07:00
|
|
|
voter.addVotingItem(adminOrg, _orgId, _enodeId, _account, 1);
|
|
|
|
org.addOrg(_orgId);
|
2019-04-08 07:26:13 -07:00
|
|
|
nodes.addNode(_enodeId, _orgId);
|
|
|
|
require(validateAccount(_account, _orgId) == true, "Operation cannot be performed");
|
2019-04-23 23:40:28 -07:00
|
|
|
accounts.assignAdminRole(_account, _orgId, orgAdminRole, 1);
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// functions to approve a new org into the network
|
2019-04-08 23:58:30 -07:00
|
|
|
function approveOrg(string calldata _orgId, string calldata _enodeId, address _account, address _caller) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-19 02:15:51 -07:00
|
|
|
networkAdmin(_caller)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-03-28 02:53:11 -07:00
|
|
|
require(checkOrgStatus(_orgId, 1) == true, "Nothing to approve");
|
|
|
|
if ((processVote(adminOrg, _caller, 1))) {
|
2019-03-14 23:41:04 -07:00
|
|
|
org.approveOrg(_orgId);
|
2019-04-26 01:35:51 -07:00
|
|
|
roles.addRole(orgAdminRole, _orgId, fullAccess, true, true);
|
2019-03-28 02:53:11 -07:00
|
|
|
nodes.approveNode(_enodeId, _orgId);
|
2019-04-23 23:40:28 -07:00
|
|
|
accounts.addNewAdmin(_orgId, _account);
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// function for adding a new sub org under a master org or another sub org
|
2019-04-08 23:58:30 -07:00
|
|
|
function addSubOrg(string calldata _pOrg, string calldata _orgId, string calldata _enodeId, address _account, address _caller) external
|
|
|
|
orgExists(_pOrg)
|
|
|
|
orgAdmin(_caller, _pOrg)
|
2019-04-03 07:25:01 -07:00
|
|
|
{
|
2019-04-08 23:58:30 -07:00
|
|
|
org.addSubOrg(_pOrg, _orgId);
|
|
|
|
string memory pid = string(abi.encodePacked(_pOrg, ".", _orgId));
|
|
|
|
if (bytes(_enodeId).length > 0) {
|
|
|
|
nodes.addNode(_enodeId, pid);
|
|
|
|
}
|
|
|
|
if (_account != address(0)) {
|
|
|
|
require(validateAccount(_account, pid) == true, "Operation cannot be performed");
|
2019-04-26 01:35:51 -07:00
|
|
|
accounts.assignAccountRole(_account, pid, orgAdminRole, true);
|
2019-04-08 23:58:30 -07:00
|
|
|
}
|
2019-04-03 07:25:01 -07:00
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// function to update the org status
|
2019-04-01 03:22:41 -07:00
|
|
|
function updateOrgStatus(string calldata _orgId, uint _status, address _caller) external
|
2019-03-28 02:53:11 -07:00
|
|
|
onlyProxy
|
2019-04-01 03:22:41 -07:00
|
|
|
networkAdmin(_caller)
|
2019-03-28 02:53:11 -07:00
|
|
|
{
|
|
|
|
uint pendingOp;
|
|
|
|
pendingOp = org.updateOrg(_orgId, _status);
|
|
|
|
voter.addVotingItem(adminOrg, _orgId, "", address(0), pendingOp);
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// function to approve the org status update
|
2019-04-01 03:22:41 -07:00
|
|
|
function approveOrgStatus(string calldata _orgId, uint _status, address _caller) external
|
2019-03-28 02:53:11 -07:00
|
|
|
onlyProxy
|
2019-04-01 03:22:41 -07:00
|
|
|
networkAdmin(_caller)
|
2019-03-28 02:53:11 -07:00
|
|
|
{
|
2019-04-03 07:25:01 -07:00
|
|
|
require((_status == 3 || _status == 5), "Operation not allowed");
|
2019-03-28 02:53:11 -07:00
|
|
|
uint pendingOp;
|
|
|
|
if (_status == 3) {
|
|
|
|
pendingOp = 2;
|
|
|
|
}
|
|
|
|
else if (_status == 5) {
|
|
|
|
pendingOp = 3;
|
|
|
|
}
|
|
|
|
require(checkOrgStatus(_orgId, _status) == true, "Operation not allowed");
|
2019-04-02 19:13:05 -07:00
|
|
|
if ((processVote(adminOrg, _caller, pendingOp))) {
|
2019-03-28 02:53:11 -07:00
|
|
|
org.approveOrgStatusUpdate(_orgId, _status);
|
|
|
|
}
|
|
|
|
}
|
2019-03-14 23:41:04 -07:00
|
|
|
|
|
|
|
// Role related functions
|
2019-05-10 00:17:01 -07:00
|
|
|
|
|
|
|
// function to add a new role ot a org
|
2019-04-26 01:35:51 -07:00
|
|
|
function addNewRole(string calldata _roleId, string calldata _orgId, uint _access, bool _voter, bool _admin, address _caller) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-14 23:41:04 -07:00
|
|
|
orgApproved(_orgId)
|
2019-03-27 04:07:01 -07:00
|
|
|
orgAdmin(_caller, _orgId)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
|
|
|
//add new roles can be created by org admins only
|
2019-04-26 01:35:51 -07:00
|
|
|
roles.addRole(_roleId, _orgId, _access, _voter, _admin);
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// function to remove a role from an org
|
2019-04-03 07:25:01 -07:00
|
|
|
function removeRole(string calldata _roleId, string calldata _orgId, address _caller) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-14 23:41:04 -07:00
|
|
|
orgApproved(_orgId)
|
2019-03-29 01:47:14 -07:00
|
|
|
orgAdmin(_caller, _orgId)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-04-05 02:16:08 -07:00
|
|
|
require(((keccak256(abi.encodePacked(_roleId)) != keccak256(abi.encodePacked(adminRole))) &&
|
|
|
|
(keccak256(abi.encodePacked(_roleId)) != keccak256(abi.encodePacked(orgAdminRole)))), "Admin roles cannot be removed");
|
2019-03-14 23:41:04 -07:00
|
|
|
roles.removeRole(_roleId, _orgId);
|
2019-04-04 03:25:43 -07:00
|
|
|
}
|
2019-03-14 23:41:04 -07:00
|
|
|
|
2019-04-08 01:57:36 -07:00
|
|
|
// Account related functions
|
2019-05-10 00:17:01 -07:00
|
|
|
// function to assign network admin role. can be called by network admin only
|
2019-04-23 23:40:28 -07:00
|
|
|
function assignAdminRole(string calldata _orgId, address _account, string calldata _roleId, address _caller) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-14 23:41:04 -07:00
|
|
|
orgExists(_orgId)
|
2019-03-28 02:53:11 -07:00
|
|
|
networkAdmin(_caller)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-04-23 23:40:28 -07:00
|
|
|
accounts.assignAdminRole(_account, _orgId, _roleId, 1);
|
2019-03-14 23:41:04 -07:00
|
|
|
//add voting item
|
|
|
|
voter.addVotingItem(adminOrg, _orgId, "", _account, 4);
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// function to approve admin role assignment to an account
|
2019-04-23 23:40:28 -07:00
|
|
|
function approveAdminRole(string calldata _orgId, address _account, address _caller) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-19 02:15:51 -07:00
|
|
|
networkAdmin(_caller)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-03-28 02:53:11 -07:00
|
|
|
if ((processVote(adminOrg, _caller, 4))) {
|
2019-04-23 23:40:28 -07:00
|
|
|
(bool ret, address acct) = accounts.removeExistingAdmin(_orgId);
|
|
|
|
if (ret) {
|
|
|
|
updateVoterList(adminOrg, acct, false);
|
|
|
|
}
|
|
|
|
bool ret1 = accounts.addNewAdmin(_orgId, _account);
|
|
|
|
if (ret1) {
|
|
|
|
updateVoterList(adminOrg, _account, true);
|
|
|
|
}
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// function to assign role and org to an account
|
2019-04-04 03:25:43 -07:00
|
|
|
function assignAccountRole(address _acct, string memory _orgId, string memory _roleId, address _caller) public
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-27 04:07:01 -07:00
|
|
|
orgAdmin(_caller, _orgId)
|
2019-03-28 02:53:11 -07:00
|
|
|
orgApproved(_orgId)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
|
|
|
require(validateAccount(_acct, _orgId) == true, "Operation cannot be performed");
|
2019-03-28 02:53:11 -07:00
|
|
|
require(roleExists(_roleId, _orgId) == true, "role does not exists");
|
2019-04-26 01:35:51 -07:00
|
|
|
bool admin = roles.isAdminRole(_roleId, _orgId, getUltimateParent(_orgId));
|
|
|
|
accounts.assignAccountRole(_acct, _orgId, _roleId, admin);
|
2019-04-04 03:25:43 -07:00
|
|
|
}
|
2019-03-14 23:41:04 -07:00
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// function to update the account status
|
2019-04-14 21:32:06 -07:00
|
|
|
function updateAccountStatus(string calldata _orgId, address _account, uint _status, address _caller) external
|
|
|
|
onlyProxy
|
|
|
|
orgAdmin(_caller, _orgId)
|
|
|
|
{
|
|
|
|
accounts.updateAccountStatus(_orgId, _account, _status);
|
|
|
|
}
|
2019-04-08 01:57:36 -07:00
|
|
|
|
|
|
|
// Node related functions
|
2019-05-10 00:17:01 -07:00
|
|
|
|
|
|
|
// function to add node
|
2019-03-27 04:07:01 -07:00
|
|
|
function addNode(string calldata _orgId, string calldata _enodeId, address _caller) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-14 23:41:04 -07:00
|
|
|
orgApproved(_orgId)
|
2019-03-27 04:07:01 -07:00
|
|
|
orgAdmin(_caller, _orgId)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
|
|
|
// check that the node is not part of another org
|
|
|
|
nodes.addOrgNode(_enodeId, _orgId);
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// function to udpate node status
|
2019-04-08 01:57:36 -07:00
|
|
|
function updateNodeStatus(string calldata _orgId, string calldata _enodeId, uint _status, address _caller) external
|
|
|
|
onlyProxy
|
|
|
|
orgAdmin(_caller, _orgId)
|
|
|
|
{
|
|
|
|
nodes.updateNodeStatus(_enodeId, _orgId, _status);
|
|
|
|
}
|
2019-04-04 03:25:43 -07:00
|
|
|
|
2019-04-08 01:57:36 -07:00
|
|
|
// Get network boot status
|
|
|
|
function getNetworkBootStatus() external view
|
|
|
|
returns (bool)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-04-08 01:57:36 -07:00
|
|
|
return networkBoot;
|
|
|
|
}
|
2019-04-04 03:25:43 -07:00
|
|
|
|
2019-04-08 01:57:36 -07:00
|
|
|
// Voter related functions
|
2019-05-10 00:17:01 -07:00
|
|
|
// function to add new network admin account to network level voter list
|
2019-04-08 01:57:36 -07:00
|
|
|
function updateVoterList(string memory _orgId, address _account, bool _add) internal
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-04-08 01:57:36 -07:00
|
|
|
if (_add) {
|
|
|
|
voter.addVoter(_orgId, _account);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
voter.deleteVoter(_orgId, _account);
|
|
|
|
}
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// function to process vote
|
2019-04-08 01:57:36 -07:00
|
|
|
function processVote(string memory _orgId, address _caller, uint _pendingOp) internal
|
|
|
|
returns (bool)
|
|
|
|
{
|
|
|
|
return voter.processVote(_orgId, _caller, _pendingOp);
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:17:01 -07:00
|
|
|
// returns pending approval operation at network admin org level. at any time
|
|
|
|
// only one pending op is allowed
|
2019-04-08 01:57:36 -07:00
|
|
|
function getPendingOp(string calldata _orgId) external view
|
|
|
|
returns (string memory, string memory, address, uint)
|
|
|
|
{
|
|
|
|
return voter.getPendingOpDetails(_orgId);
|
|
|
|
}
|
|
|
|
|
|
|
|
// helper functions
|
2019-03-15 02:26:57 -07:00
|
|
|
function isNetworkAdmin(address _account) public view
|
|
|
|
returns (bool)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
|
|
|
return (keccak256(abi.encodePacked(accounts.getAccountRole(_account))) == keccak256(abi.encodePacked(adminRole)));
|
|
|
|
}
|
|
|
|
|
2019-04-04 03:25:43 -07:00
|
|
|
function isOrgAdmin(address _account, string memory _orgId) public view
|
2019-03-15 02:26:57 -07:00
|
|
|
returns (bool)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-04-26 01:35:51 -07:00
|
|
|
if (accounts.checkOrgAdmin(_account, _orgId, getUltimateParent(_orgId))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return roles.isAdminRole(accounts.getAccountRole(_account), _orgId, getUltimateParent(_orgId));
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
|
2019-03-15 02:26:57 -07:00
|
|
|
function validateAccount(address _account, string memory _orgId) public view
|
|
|
|
returns (bool)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-04-23 23:40:28 -07:00
|
|
|
return (accounts.validateAccount(_account, _orgId));
|
2019-04-04 03:25:43 -07:00
|
|
|
}
|
2019-03-14 23:41:04 -07:00
|
|
|
|
2019-03-28 02:53:11 -07:00
|
|
|
function checkOrgExists(string memory _orgId) internal view
|
|
|
|
returns (bool)
|
|
|
|
{
|
|
|
|
return org.checkOrgExists(_orgId);
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkOrgApproved(string memory _orgId) internal view
|
|
|
|
returns (bool)
|
|
|
|
{
|
|
|
|
return org.checkOrgStatus(_orgId, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkOrgStatus(string memory _orgId, uint _status) internal view
|
|
|
|
returns (bool)
|
|
|
|
{
|
|
|
|
return org.checkOrgStatus(_orgId, _status);
|
|
|
|
}
|
2019-04-03 07:25:01 -07:00
|
|
|
|
2019-04-21 18:51:03 -07:00
|
|
|
function checkOrgAdminExists(string memory _orgId) internal view
|
|
|
|
returns (bool)
|
|
|
|
{
|
|
|
|
return accounts.orgAdminExists(_orgId);
|
|
|
|
}
|
|
|
|
|
2019-03-28 02:53:11 -07:00
|
|
|
function roleExists(string memory _roleId, string memory _orgId) internal view
|
|
|
|
returns (bool)
|
|
|
|
{
|
2019-04-09 20:10:35 -07:00
|
|
|
return roles.roleExists(_roleId, _orgId, org.getUltimateParent(_orgId));
|
2019-03-28 02:53:11 -07:00
|
|
|
}
|
2019-04-03 07:25:01 -07:00
|
|
|
|
2019-03-28 02:53:11 -07:00
|
|
|
function isVoterRole(string memory _roleId, string memory _orgId) internal view
|
|
|
|
returns (bool)
|
|
|
|
{
|
2019-04-09 22:59:15 -07:00
|
|
|
return roles.isVoterRole(_roleId, _orgId, getUltimateParent(_orgId));
|
|
|
|
}
|
|
|
|
|
|
|
|
function getUltimateParent(string memory _orgId) internal view
|
|
|
|
returns (string memory)
|
|
|
|
{
|
|
|
|
return org.getUltimateParent(_orgId);
|
2019-03-28 02:53:11 -07:00
|
|
|
}
|
|
|
|
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|