< Summary

Information
Class: Chronicis.Client.Services.AdminAuthService
Assembly: Chronicis.Client
File(s): /home/runner/work/chronicis/chronicis/src/Chronicis.Client/Services/AdminAuthService.cs
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 38
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%

File(s)

/home/runner/work/chronicis/chronicis/src/Chronicis.Client/Services/AdminAuthService.cs

#LineLine coverage
 1using Chronicis.Shared.Admin;
 2
 3namespace Chronicis.Client.Services;
 4
 5/// <summary>
 6/// System admin authorization service.
 7/// Delegates to <see cref="ISysAdminChecker"/> which reads from the "SysAdmin"
 8/// configuration section, eliminating hardcoded identity sets.
 9/// </summary>
 10public class AdminAuthService : IAdminAuthService
 11{
 12    private readonly IAuthService _authService;
 13    private readonly ISysAdminChecker _sysAdminChecker;
 14    private readonly ILogger<AdminAuthService> _logger;
 15
 16    public AdminAuthService(
 17        IAuthService authService,
 18        ISysAdminChecker sysAdminChecker,
 19        ILogger<AdminAuthService> logger)
 20    {
 521        _authService = authService;
 522        _sysAdminChecker = sysAdminChecker;
 523        _logger = logger;
 524    }
 25
 26    /// <inheritdoc/>
 27    public async Task<bool> IsSysAdminAsync()
 28    {
 29        var user = await _authService.GetCurrentUserAsync();
 30        if (user == null)
 31        {
 32            _logger.LogDebug("IsSysAdminAsync: no current user, returning false");
 33            return false;
 34        }
 35
 36        return _sysAdminChecker.IsSysAdmin(user.Auth0UserId, user.Email);
 37    }
 38}