public bool isPermitToStage(IPermissionIdentity identity, string awaitingStage, string action = null) { if (action == null) { if (awaitingStage.ToUpper() == "SUBMIT") { action = "submit"; } else { action = "approve"; } } //use for check user has authorize to action(approve) at awaiiting stage or not awaitingStage = awaitingStage.ToUpper(); if (!_nodeDict.ContainsKey(awaitingStage)) { log("ERROR", "CONFIG ERROR:CANNOT FIND STAGE IN CONFIG : " + awaitingStage); return(false); } var stagePermissions = _nodeDict[awaitingStage].Permissions.Where(x => x.Action.ToLower() == action.ToLower()); return(CheckPermission(stagePermissions, identity)); }
} //MT_1 public bool isFlowInitiator(IPermissionIdentity identity) { //check if current user has right to initiate flow or not if (_submitNode == null) { return(false); } else { var submitPermission = _submitNode.Permissions.Where(x => x.Action.ToLower() == "Submit".ToLower()); return(CheckPermission(submitPermission, identity)); } }
private bool CheckPermission(IEnumerable <Permission> permissions, IPermissionIdentity identity) { foreach (var permission in permissions) { foreach (var permissionCard in permission.PermissionCards) { if (permissionCard.Type == PermissionType.GROUP) { if (identity.PermissionCards.Any(x => x.RoleName.ToLower() == permissionCard.RoleName.ToLower() && (x.RoleLevel == permissionCard.RoleLevel || permissionCard.RoleLevel == -1))) { return(true); } } else if (permissionCard.Type == PermissionType.INDIVIDUAL) { if (identity.Username.ToLower() == permissionCard.RoleName.ToLower()) { return(true); } } } } return(false); }