< Summary

Information
Class: Api.Auth.Utils.CurrentUserId
Assembly: Api
File(s): /home/runner/work/ProjectRead.ing/ProjectRead.ing/Api/Auth/Utils/UserIdService.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 24
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/UserIdService.cs

#LineLine coverage
 1// SPDX-FileCopyrightText: 2026 Alper Çelik <[email protected]>
 2//
 3// SPDX-License-Identifier: AGPL-3.0-or-later
 4
 5using System.Security.Claims;
 6
 7namespace Api.Auth.Utils;
 8
 9public interface ICurrentUserId
 10{
 11    public Guid? Id { get; }
 12}
 13
 14public class CurrentUserId : ICurrentUserId
 15{
 16    public Guid? Id { get; init; }
 017    public CurrentUserId(IHttpContextAccessor ctx)
 018    {
 019        if (ctx.HttpContext?.User.FindFirstValue(ClaimTypes.NameIdentifier) is { } userIdStr && Guid.TryParse(userIdStr,
 020        {
 021            Id = userId;
 022        }
 023    }
 24}