< Summary

Information
Class: Api.Auth.Utils.CurrentServiceId
Assembly: Api
File(s): /home/runner/work/ProjectRead.ing/ProjectRead.ing/Api/Auth/Utils/ServiceIdService.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 11
Coverable lines: 11
Total lines: 30
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)0%4260%

File(s)

/home/runner/work/ProjectRead.ing/ProjectRead.ing/Api/Auth/Utils/ServiceIdService.cs

#LineLine coverage
 1// SPDX-FileCopyrightText: 2026 Alper Çelik <alper@alper-celik.dev>
 2//
 3// SPDX-License-Identifier: AGPL-3.0-or-later
 4
 5using System.Security.Claims;
 6using Api.Auth.Models;
 7
 8namespace Api.Auth.Utils;
 9
 10public interface ICurrentServiceId
 11{
 12    public Guid? Id { get; }
 13}
 14
 15public class CurrentServiceId : ICurrentServiceId
 16{
 17    public Guid? Id { get; init; }
 18
 019    public CurrentServiceId(IHttpContextAccessor ctx)
 020    {
 021        if (
 022            ctx.HttpContext?.User.FindFirstValue(RemoteServiceToken.ServiceIdentifierType)
 023                is { } serviceIdStr
 024            && Guid.TryParse(serviceIdStr, out Guid serviceId)
 025        )
 026        {
 027            Id = serviceId;
 028        }
 029    }
 30}