- splits the admin part of RBAC.sol into RBACWithAdmin.solpull/863/head^2
parent
a9c777faa6
commit
a6bef44790
@ -0,0 +1,60 @@ |
||||
pragma solidity ^0.4.18; |
||||
|
||||
import "./RBAC.sol"; |
||||
|
||||
|
||||
/** |
||||
* @title RBACWithAdmin |
||||
* @author Matt Condon (@Shrugs) |
||||
* @dev It's recommended that you define constants in the contract, |
||||
* @dev like ROLE_ADMIN below, to avoid typos. |
||||
*/ |
||||
contract RBACWithAdmin is RBAC { |
||||
/** |
||||
* A constant role name for indicating admins. |
||||
*/ |
||||
string public constant ROLE_ADMIN = "admin"; |
||||
|
||||
/** |
||||
* @dev modifier to scope access to admins |
||||
* // reverts |
||||
*/ |
||||
modifier onlyAdmin() |
||||
{ |
||||
checkRole(msg.sender, ROLE_ADMIN); |
||||
_; |
||||
} |
||||
|
||||
/** |
||||
* @dev constructor. Sets msg.sender as admin by default |
||||
*/ |
||||
function RBACWithAdmin() |
||||
public |
||||
{ |
||||
addRole(msg.sender, ROLE_ADMIN); |
||||
} |
||||
|
||||
/** |
||||
* @dev add a role to an address |
||||
* @param addr address |
||||
* @param roleName the name of the role |
||||
*/ |
||||
function adminAddRole(address addr, string roleName) |
||||
onlyAdmin |
||||
public |
||||
{ |
||||
addRole(addr, roleName); |
||||
} |
||||
|
||||
/** |
||||
* @dev remove a role from an address |
||||
* @param addr address |
||||
* @param roleName the name of the role |
||||
*/ |
||||
function adminRemoveRole(address addr, string roleName) |
||||
onlyAdmin |
||||
public |
||||
{ |
||||
removeRole(addr, roleName); |
||||
} |
||||
} |
Loading…
Reference in new issue