refactor(UserLogin): Id umbenannt in UserId

This commit is contained in:
Developer 02 2025-03-10 17:05:05 +01:00
parent 85ccc52ca1
commit 583864469c
2 changed files with 5 additions and 6 deletions

View File

@ -48,6 +48,8 @@ namespace DigitalData.Auth.API.Controllers
private async Task<IActionResult> CreateTokenAsync(UserLogin login, string consumerName, bool cookie = true)
{
DataResult<UserReadDto>? uRes;
if(login.Username is not null && login.UserId is not null)
return BadRequest("Both user ID and username cannot be provided.");
if (login.Username is not null)
{
bool isValid = await _dirSearchService.ValidateCredentialsAsync(login.Username, login.Password);
@ -59,7 +61,7 @@ namespace DigitalData.Auth.API.Controllers
if (uRes.IsFailed)
return Unauthorized();
}
else if(login.Id is int userId)
else if(login.UserId is int userId)
{
uRes = await _userService.ReadByIdAsync(userId);
if (uRes.IsFailed)
@ -72,7 +74,7 @@ namespace DigitalData.Auth.API.Controllers
}
else
{
return BadRequest("One of user ID or username should be provided.");
return BadRequest("User ID or username should be provided.");
}
//find the user

View File

@ -1,6 +1,3 @@
namespace DigitalData.Auth.API.Dto;
public record UserLogin(string Password, int? Id = null, string? Username = null)
{
public bool Valid => Id is not null || !string.IsNullOrWhiteSpace(Username);
};
public record UserLogin(string Password, int? UserId = null, string? Username = null);