< Summary

Information
Class: Syki.Back.Features.Cross.ResetPassword.ResetPasswordService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Cross/ResetPassword/ResetPasswordService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 29
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
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%
Reset()100%66100%

File(s)

/home/runner/work/syki/syki/Back/Features/Cross/ResetPassword/ResetPasswordService.cs

#LineLine coverage
 1using Syki.Back.Features.Cross.CreateUser;
 2
 3namespace Syki.Back.Features.Cross.ResetPassword;
 4
 1375public class ResetPasswordService(SykiDbContext ctx, UserManager<SykiUser> userManager) : ICrossService
 6{
 7    public async Task<OneOf<SykiSuccess, SykiError>> Reset(ResetPasswordIn body)
 8    {
 1379        _ = Guid.TryParse(body.Token, out var id);
 13710        var reset = await ctx.ResetPasswordTokens.FirstOrDefaultAsync(r => r.Id == id);
 15711        if (reset == null) return new UserNotFound();
 12
 11713        var user = await userManager.FindByIdAsync(reset!.UserId.ToString());
 14
 11715        var result = await userManager.ResetPasswordAsync(user!, reset.Token, body.Password);
 16
 11717        if (!result.Succeeded)
 18        {
 3619            if (result.Errors.Any(e => e.Code == "InvalidToken")) return new InvalidResetToken();
 20
 821            return new WeakPassword();
 22        }
 23
 10824        reset.Use();
 10825        await ctx.SaveChangesAsync();
 26
 10827        return new SykiSuccess();
 13728    }
 29}