コード例 #1
0
        public IActionResult ChangeUnsureSave(
            [FromServices] IRoleBasedPermissionRuleRepository checkFeatureRuleRepository,
            [FromServices] IPermissionRuleActionPoolService poolService,
            [FromServices] IPermissionRuleActionPool pool,
            string mode = null)
        {
            var checkFeatureRules = checkFeatureRuleRepository.GetRules();

            var checkFeatureRule = checkFeatureRules.GetRule(KnownPermissionIds.UnsureOp, false);

            if (checkFeatureRule != null)
            {
                if ("guestAllowed".Equals(mode, StringComparison.OrdinalIgnoreCase))
                {
                    checkFeatureRule.SetNeedGuest();
                }
                if ("loginAllowed".Equals(mode, StringComparison.OrdinalIgnoreCase))
                {
                    checkFeatureRule.SetNeedLogin();
                }
                if ("adminAllowed".Equals(mode, StringComparison.OrdinalIgnoreCase))
                {
                    checkFeatureRule.SetNeedUsersOrRoles("", "Admin");
                }
                checkFeatureRuleRepository.Save();
                poolService.RefreshPool(pool);
            }
            return(RedirectToAction("Unsure", "Simple"));
        }
コード例 #2
0
        public void SetRuleActions(IPermissionRuleActionPool ruleActionPool)
        {
            var rules   = _ruleRepository.GetRules();
            var actions = _actionRepository.GetActions();

            ruleActionPool.SetRoleBasedPermissionRules(rules.Values, true);
            ruleActionPool.SetDynamicCheckActions(actions, true);
        }