< Summary

Information
Class: LGDXRobotCloud.API.Areas.Identity.Controllers.AuthController
Assembly: LGDXRobotCloud.API
File(s): /builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.API/Areas/Identity/Controllers/AuthController.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 18
Coverable lines: 18
Total lines: 57
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)0%620%
Login()100%210%
ForgotPassword()100%210%
ResetPassword()100%210%
Refresh()100%210%

File(s)

/builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.API/Areas/Identity/Controllers/AuthController.cs

#LineLine coverage
 1using LGDXRobotCloud.API.Services.Identity;
 2using LGDXRobotCloud.Data.Models.Business.Identity;
 3using LGDXRobotCloud.Data.Models.DTOs.V1.Requests;
 4using LGDXRobotCloud.Data.Models.DTOs.V1.Responses;
 5using Microsoft.AspNetCore.Authentication.JwtBearer;
 6using Microsoft.AspNetCore.Authorization;
 7using Microsoft.AspNetCore.Mvc;
 8
 9namespace LGDXRobotCloud.API.Areas.Identity.Controllers;
 10
 11[ApiController]
 12[Area("Identity")]
 13[Route("[area]/[controller]")]
 14[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
 015public sealed class AuthController(IAuthService authService) : ControllerBase
 16{
 017  private readonly IAuthService _authService = authService ?? throw new ArgumentNullException(nameof(authService));
 18
 19  [AllowAnonymous]
 20  [HttpPost("Login")]
 21  [ProducesResponseType(typeof(LoginResponseDto), StatusCodes.Status200OK)]
 22  [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
 23  public async Task<ActionResult<LoginResponseDto>>Login(LoginRequestDto loginRequestDto)
 024  {
 025    var result = await _authService.LoginAsync(loginRequestDto.ToBusinessModel());
 026    return Ok(result.ToDto());
 027  }
 28
 29  [AllowAnonymous]
 30  [HttpPost("ForgotPassword")]
 31  [ProducesResponseType(StatusCodes.Status200OK)]
 32  public async Task<ActionResult> ForgotPassword(ForgotPasswordRequestDto forgotPasswordRequestDto)
 033  {
 034    await _authService.ForgotPasswordAsync(forgotPasswordRequestDto.ToBusinessModel());
 035    return Ok();
 036  }
 37
 38  [AllowAnonymous]
 39  [HttpPost("ResetPassword")]
 40  [ProducesResponseType(StatusCodes.Status200OK)]
 41  [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
 42  public async Task<ActionResult> ResetPassword(ResetPasswordRequestDto resetPasswordRequestDto)
 043  {
 044    await _authService.ResetPasswordAsync(resetPasswordRequestDto.ToBusinessModel());
 045    return Ok();
 046  }
 47
 48  [AllowAnonymous]
 49  [HttpPost("Refresh")]
 50  [ProducesResponseType(typeof(RefreshTokenResponseDto), StatusCodes.Status200OK)]
 51  [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
 52  public async Task<ActionResult> Refresh(RefreshTokenRequestDto refreshTokenRequestDto)
 053  {
 054    var result = await _authService.RefreshTokenAsync(refreshTokenRequestDto.ToBusinessModel());
 055    return Ok(result.ToDto());
 056  }
 57}