< Summary - Syki

Information
Class: Syki.Back.Features.Identity.SetupTwoFactor.SetupTwoFactorService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Identity/SetupTwoFactor/SetupTwoFactorService.cs
Tag: 56_26538939494
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 19
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

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

File(s)

/home/runner/work/syki/syki/Back/Features/Identity/SetupTwoFactor/SetupTwoFactorService.cs

#LineLine coverage
 1using Syki.Back.Domain.Identity;
 2
 3namespace Syki.Back.Features.Identity.SetupTwoFactor;
 4
 345public class SetupTwoFactorService(SykiDbContext ctx, UserManager<SykiUser> userManager) : ISykiService
 6{
 7    public async Task<OneOf<SykiSuccess, SykiError>> Setup(string token)
 8    {
 349        var webUser = await userManager.Users.FirstAsync(u => u.Id == ctx.RequestUser.Id);
 10
 3411        var tokenProvider = userManager.Options.Tokens.AuthenticatorTokenProvider;
 3412        var valid = await userManager.VerifyTwoFactorTokenAsync(webUser, tokenProvider, token.OnlyNumbers());
 4813        if (!valid) return InvalidTwoFactorToken.I;
 14
 2015        await userManager.SetTwoFactorEnabledAsync(webUser, true);
 16
 2017        return SykiSuccess.I;
 3418    }
 19}