< Summary

Information
Class: Api.Auth.Queries.User
Assembly: Api
File(s): /home/runner/work/ProjectRead.ing/ProjectRead.ing/Api/Auth/Queries/CurrentUser.cs
Line coverage
71%
Covered lines: 10
Uncovered lines: 4
Coverable lines: 14
Total lines: 61
Line coverage: 71.4%
Branch coverage
0%
Covered branches: 0
Total branches: 4
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(...)100%11100%
get_IdPostfix()100%11100%
GetUserAsync()0%2040%

File(s)

/home/runner/work/ProjectRead.ing/ProjectRead.ing/Api/Auth/Queries/CurrentUser.cs

#LineLine coverage
 1// SPDX-FileCopyrightText: 2026 Alper Çelik <[email protected]>
 2//
 3// SPDX-License-Identifier: AGPL-3.0-or-later
 4
 5using Api.Auth.Handlers;
 6using Api.Auth.Models;
 7using Api.Auth.Utils;
 8using Api.Database;
 9using Riok.Mapperly.Abstractions;
 10
 11namespace Api.Auth.Queries;
 12
 13[QueryType]
 14public partial class CurrentUserQueries
 15{
 16    [PermissionCheckAuthorize(UserPermissionBits.UserRead)]
 17    public static async Task<User> GetCurrentUser(
 18        [Service] PGContext db,
 19        [Service] ICurrentUserId id,
 20        CancellationToken ct
 21    )
 22    {
 23        return UserMapper.ToDto(
 24            await db.Users.FindAsync([id.Id], cancellationToken: ct)
 25        )!;
 26    }
 27}
 28
 29[Node]
 130public record User(
 131    Guid Id,
 132    int RowVersion,
 133    NodaTime.Instant MetadataAddedAt,
 134    NodaTime.Instant MetadataUpdatedAt,
 135    string Email,
 136    bool EmailVerified,
 137    bool Admin
 138) : IEntityMetadata, INode
 39{
 140    public static byte IdPostfix => UserEF.IdPostfix;
 41
 42    [PermissionCheckAuthorize(UserPermissionBits.UserRead)]
 43    public static async Task<User?> GetUserAsync(
 44        [Service] PGContext db,
 45        Guid id,
 46        CancellationToken ct
 47    )
 048    {
 049        var user = await db.Users.FindAsync([id], cancellationToken: ct);
 050        return user?.Id == id ? UserMapper.ToDto(user) : null;
 051    }
 52}
 53
 54[Mapper]
 55public static partial class UserMapper
 56{
 57    public static partial IQueryable<User> ProjectToDto(IQueryable<UserEF> q);
 58
 59    [MapperIgnoreSource(nameof(UserEF.PasswordHash))]
 60    public static partial User? ToDto(UserEF? o);
 61}