refactor(UserLogin): Id umbenannt in UserId
This commit is contained in:
parent
85ccc52ca1
commit
583864469c
@ -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
|
||||
|
||||
@ -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);
|
||||
Loading…
x
Reference in New Issue
Block a user