Beispiel #1
0
        public void RemoveRoleTest()
        {
            cache.AddRole("resouce:operation", tenantId, "operator");

            Assert.IsTrue(cache.GetRoles("resouce:operation", tenantId).Contains("operator"));

            cache.RemoveRole("resouce:operation", tenantId, "operator");

            Assert.IsFalse(cache.GetRoles("resouce:operation", tenantId).Contains("operator"));
        }
        async Task IMultiTenantIamProvider <TTenantKey> .RemoveRole(string policyName, TTenantKey tenantId, string roleName, IMultiTenantIamProviderCache <TTenantKey> cache)
        {
            var policyId = await CreateOrGetPolicy(policyName);

            var role = await _roleManager.FindByNameAsync(roleName);

            if (role != null)
            {
                var iamRole = await _context.IamPolicyRoles.FirstOrDefaultAsync(x => x.PolicyId.Equals(policyId) && x.RoleId.Equals(role.Id) && x.TenantId.Equals(tenantId));

                if (iamRole != null)
                {
                    _context.IamPolicyRoles.Remove(iamRole);

                    await _context.SaveChangesAsync();
                }

                cache.RemoveRole(policyName, tenantId, roleName);
            }
        }
        Task IMultiTenantIamProvider <TTenantKey> .RemoveRole(string policyName, TTenantKey tenantId, string roleName, IMultiTenantIamProviderCache <TTenantKey> cache)
        {
            cache.RemoveRole(policyName, tenantId, roleName);

            return(Task.CompletedTask);
        }