< Summary - Syki

Information
Class: Syki.Front.Auth.AuthManager
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Auth/AuthManager.cs
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 26
Line coverage: 0%
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%210%
GetUser()0%2040%

File(s)

/home/runner/work/syki/syki/Front/Auth/AuthManager.cs

#LineLine coverage
 1using Microsoft.AspNetCore.Components.Authorization;
 2
 3namespace Syki.Front.Auth;
 4
 05public class AuthManager(AuthenticationStateProvider provider)
 6{
 7    public async Task<AuthUser> GetUser()
 8    {
 09        var authState = await provider.GetAuthenticationStateAsync();
 010        var user = authState.User;
 11
 012        if (user.Identity is not { IsAuthenticated: true })
 13        {
 014            return new AuthUser();
 15        }
 16
 017        return new AuthUser
 018        {
 019            IsAuthenticated = true,
 020            Id = Guid.Parse(user.FindFirst("sub").Value),
 021            Name = user.FindFirst("name").Value,
 022            Email = user.FindFirst("email").Value,
 023            Role = Enum.Parse<UserRole>(user.FindFirst("role").Value),
 024        };
 025    }
 26}