Skip to content

Commit

Permalink
Merge branch 'main' into fix/watt-filter-chip-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ManBearTM authored Oct 3, 2024
2 parents 6e746eb + acf62dd commit 9621a49
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
using Energinet.DataHub.WebApi.Clients.MarketParticipant.v1;
using Energinet.DataHub.WebApi.Extensions;

namespace Energinet.DataHub.WebApi.GraphQL.Query;

Expand All @@ -34,6 +35,20 @@ public async Task<UserRoleWithPermissionsDto> GetUserRoleByIdAsync(
await client.UserRolesGetAsync(id);

public async Task<IEnumerable<UserRoleDto>> GetUserRolesAsync(
[Service] IMarketParticipantClient_V1 client) =>
await client.UserRolesGetAsync();
[Service] IHttpContextAccessor httpContext,
[Service] IMarketParticipantClient_V1 client)
{
if (httpContext.HttpContext == null)
{
return Enumerable.Empty<UserRoleDto>();
}

var user = httpContext.HttpContext.User;
if (user.IsFas())
{
return await client.UserRolesGetAsync();
}

return await client.ActorsRolesAsync(user.GetAssociatedActor());
}
}

0 comments on commit 9621a49

Please sign in to comment.