internal static bool IsActionAccessible(string actionCode, out BackendAction action) { using (new QPConnectionScope()) { action = BackendActionRepository.GetByCode(actionCode); if (action == null) { throw new ApplicationException($"Action is not found: {actionCode}"); } if (QPContext.IsAdmin) { return(true); } var actionType = BackendActionTypeRepository.GetById(action.TypeId); if (actionType == null) { throw new ApplicationException($"Action Type is not found: {action.TypeId}"); } var userPLevel = GetActionPermissionLevelForUser(action, QPContext.CurrentUserId); if (userPLevel == null) { return(false); } return(userPLevel >= actionType.RequiredPermissionLevel); } }
internal static int GetRequiredPermissionLevel(string actionTypeCode) { return(BackendActionTypeRepository.GetList() .SingleOrDefault(n => n.Code == actionTypeCode)?.RequiredPermissionLevel ?? PermissionLevel.Deny); }
public IEnumerable <BackendActionType> GetActionTypeList() { return(BackendActionTypeRepository.GetList().Where(r => r.RequiredPermissionLevel >= PermissionLevel.Modify).ToArray()); }
internal static IEnumerable <BackendActionType> GetActionTypeList() { return(BackendActionTypeRepository.GetList().Where(r => r.RequiredPermissionLevel >= 3).ToArray()); }
internal static IEnumerable <BackendAction> GetInterfaceActionsForCustom() { var refresh = BackendActionTypeRepository.GetByCode(ActionTypeCode.Refresh); return(BackendActionCache.Actions.Where(a => a.IsInterface && a.TypeId != refresh.Id).ToArray()); }