< Summary - Syki

Information
Class: Syki.Back.Features.Academic.CrossLogin.CrossLoginService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Academic/CrossLogin/CrossLoginService.cs
Tag: 21_17346963026
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 28
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%
Login()100%22100%

File(s)

/home/runner/work/syki/syki/Back/Features/Academic/CrossLogin/CrossLoginService.cs

#LineLine coverage
 1using System.IdentityModel.Tokens.Jwt;
 2using Syki.Back.Features.Cross.GenerateJWT;
 3
 4namespace Syki.Back.Features.Academic.CrossLogin;
 5
 86public class CrossLoginService(SykiDbContext ctx, GenerateJWTService service) : IAcademicService
 7{
 8    public async Task<OneOf<CrossLoginOut, SykiError>> Login(Guid institutionId, CrossLoginIn data)
 9    {
 810        var targetUser = await ctx.Users.AsNoTracking()
 811            .Where(c => c.InstitutionId == institutionId && c.Id == data.TargetUserId)
 812            .FirstOrDefaultAsync();
 13
 1214        if (targetUser == null) return new UserNotFound();
 15
 416        var jwt = await service.Generate(targetUser.Email);
 417        var claims = new JwtSecurityToken(jwt).Claims.ToList();
 18
 419        return new CrossLoginOut
 420        {
 421            AccessToken = jwt,
 1622            Name = claims.First(x => x.Type == "name").Value,
 2023            Email = claims.First(x => x.Type == "email").Value,
 824            Id = Guid.Parse(claims.First(x => x.Type == "sub").Value),
 1225            Role = Enum.Parse<UserRole>(claims.First(x => x.Type == "role").Value),
 426        };
 827    }
 28}