< Summary

Information
Class: Syki.Back.Features.Cross.SetupMfa.SetupMfaService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Cross/SetupMfa/SetupMfaService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 20
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/Cross/SetupMfa/SetupMfaService.cs

#LineLine coverage
 1using Syki.Back.Features.Cross.CreateUser;
 2
 3namespace Syki.Back.Features.Cross.SetupMfa;
 4
 125public class SetupMfaService(UserManager<SykiUser> userManager) : ICrossService
 6{
 7    public async Task<OneOf<SykiSuccess, SykiError>> Setup(Guid userId, string token)
 8    {
 129        var user = await userManager.Users.FirstAsync(u => u.Id == userId);
 10
 1211        var tokenProvider = userManager.Options.Tokens.AuthenticatorTokenProvider;
 1212        var ok = await userManager.VerifyTwoFactorTokenAsync(user, tokenProvider, token.OnlyNumbers());
 13
 1914        if (!ok) return new InvalidMfaToken();
 15
 516        await userManager.SetTwoFactorEnabledAsync(user, true);
 17
 518        return new SykiSuccess();
 1219    }
 20}