< Summary - Syki

Information
Class: Syki.Back.Features.Identity.EmailPasswordLogin.EmailPasswordLoginService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Identity/EmailPasswordLogin/EmailPasswordLoginService.cs
Tag: 56_26538939494
Line coverage
100%
Covered lines: 18
Uncovered lines: 0
Coverable lines: 18
Total lines: 37
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
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%
Login()100%88100%

File(s)

/home/runner/work/syki/syki/Back/Features/Identity/EmailPasswordLogin/EmailPasswordLoginService.cs

#LineLine coverage
 1using Syki.Back.Domain.Identity;
 2using Syki.Back.Features.Cross.SignIn;
 3
 4namespace Syki.Back.Features.Identity.EmailPasswordLogin;
 5
 626public class EmailPasswordLoginService(
 627    SignInService service,
 628    IHttpContextAccessor httpCtx,
 629    UserManager<SykiUser> userManager) : ISykiService
 10{
 11    public async Task<OneOf<EmailPasswordLoginOut, SykiError>> Login(EmailPasswordLoginIn data)
 12    {
 6213        var user = await userManager.FindByEmailAsync(data.Email);
 6614        if (user == null) return new LoginWrongEmailOrPassword();
 15
 6616        if (await userManager.IsLockedOutAsync(user)) return new LoginUserLockedOut();
 17
 5018        var isValidPassword = await userManager.CheckPasswordAsync(user, data.Password);
 5019        if (!isValidPassword)
 20        {
 1821            await userManager.AccessFailedAsync(user);
 1822            return new LoginWrongEmailOrPassword();
 23        }
 24
 25        // Reset failed access count on successful login
 3226        await userManager.ResetAccessFailedCountAsync(user);
 27
 3228        if (user.TwoFactorEnabled)
 29        {
 2030            await httpCtx.HttpContext.SignInTwoFactorUserIdSchemeAsync(user.Id);
 2031            return new LoginRequiresTwoFactor();
 32        }
 33
 1234        var signInResult = await service.SignIn(data.Email);
 1235        return signInResult.ToEmailPasswordLoginOut();
 6236    }
 37}