public static async Task <bool> IsInRoleAsync(this IUsersRolesRepository usersRoles, Guid userId, string roleName, IRolesRepository roles, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); var role = await roles.FindByNameAsync(roleName, false, cancellationToken); if (role is null) { return(false); } return(await usersRoles.FindUserRoleAsync(userId, role.Id, cancellationToken) is not null); }
protected override async Task <UserRole> FindUserRoleAsync(Guid userId, Guid roleId, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); return(await _usersRoles.FindUserRoleAsync(userId, roleId, cancellationToken)); }