| Class: | Api.Auth.Utils.CurrentServiceId |
|---|---|
| Assembly: | Api |
| File(s): | /home/runner/work/ProjectRead.ing/ProjectRead.ing/Api/Auth/Utils/ServiceIdService.cs |
| Covered lines: | 0 |
|---|---|
| Uncovered lines: | 11 |
| Coverable lines: | 11 |
| Total lines: | 30 |
| Line coverage: | 0% |
| Covered branches: | 0 |
|---|---|
| Total branches: | 6 |
| Branch coverage: | 0% |
Feature is only available for sponsors
Upgrade to PRO version| Method | Branch coverage | Crap Score | Cyclomatic complexity | Line coverage |
|---|---|---|---|---|
| .ctor(...) | 0% | 42 | 6 | 0% |
| # | Line | Line coverage | ||
|---|---|---|---|---|
1 | // SPDX-FileCopyrightText: 2026 Alper Çelik <[email protected]> | |||
2 | // | |||
3 | // SPDX-License-Identifier: AGPL-3.0-or-later | |||
4 | | |||
5 | using System.Security.Claims; | |||
6 | using Api.Auth.Models; | |||
7 | | |||
8 | namespace Api.Auth.Utils; | |||
9 | | |||
10 | public interface ICurrentServiceId | |||
11 | { | |||
12 | public Guid? Id { get; } | |||
13 | } | |||
14 | | |||
15 | public class CurrentServiceId : ICurrentServiceId | |||
16 | { | |||
17 | public Guid? Id { get; init; } | |||
18 | | |||
| 0 | 19 | public CurrentServiceId(IHttpContextAccessor ctx) | ||
| 0 | 20 | { | ||
| 0 | 21 | if ( | ||
| 0 | 22 | ctx.HttpContext?.User.FindFirstValue(RemoteServiceToken.ServiceIdentifierType) | ||
| 0 | 23 | is { } serviceIdStr | ||
| 0 | 24 | && Guid.TryParse(serviceIdStr, out Guid serviceId) | ||
| 0 | 25 | ) | ||
| 0 | 26 | { | ||
| 0 | 27 | Id = serviceId; | ||
| 0 | 28 | } | ||
| 0 | 29 | } | ||
30 | } |