diff --git a/src/DigitalData.Auth.API/Controllers/AuthController.cs b/src/DigitalData.Auth.API/Controllers/AuthController.cs index 04fc6cc..549d656 100644 --- a/src/DigitalData.Auth.API/Controllers/AuthController.cs +++ b/src/DigitalData.Auth.API/Controllers/AuthController.cs @@ -48,6 +48,8 @@ namespace DigitalData.Auth.API.Controllers private async Task CreateTokenAsync(UserLogin login, string consumerName, bool cookie = true) { DataResult? 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 diff --git a/src/DigitalData.Auth.API/Dto/UserLogin.cs b/src/DigitalData.Auth.API/Dto/UserLogin.cs index 17e4737..dbfc082 100644 --- a/src/DigitalData.Auth.API/Dto/UserLogin.cs +++ b/src/DigitalData.Auth.API/Dto/UserLogin.cs @@ -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); -}; \ No newline at end of file +public record UserLogin(string Password, int? UserId = null, string? Username = null); \ No newline at end of file