Ejemplo n.º 1
0
        private async Task ValidateRoleName(IdentityRoleManager manager, Role role,
                                            ICollection <IdentityError> errors)
        {
            var roleName = await manager.GetRoleNameAsync(role);

            if (string.IsNullOrWhiteSpace(roleName))
            {
                errors.Add(Describer.InvalidRoleName(roleName));
            }
            else
            {
                var owner = await manager.FindByNameAsync(roleName, role.CompanyId, role.TenantId);

                if (owner != null &&
                    !string.Equals(await manager.GetRoleIdAsync(owner), await manager.GetRoleIdAsync(role)))
                {
                    errors.Add(Describer.DuplicateRoleName(roleName));
                }
            }
        }