Browse Source
Fix for Nullreference exception when public api authenticate endpoint called with invalid username. (#482)
main
Onur BIYIK
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
7 additions and
2 deletions
-
src/PublicApi/AuthEndpoints/Authenticate.cs
-
tests/FunctionalTests/PublicApi/AuthEndpoints/AuthenticateEndpoint.cs
|
|
@ -42,7 +42,11 @@ namespace Microsoft.eShopWeb.PublicApi.AuthEndpoints |
|
|
response.IsNotAllowed = result.IsNotAllowed; |
|
|
response.IsNotAllowed = result.IsNotAllowed; |
|
|
response.RequiresTwoFactor = result.RequiresTwoFactor; |
|
|
response.RequiresTwoFactor = result.RequiresTwoFactor; |
|
|
response.Username = request.Username; |
|
|
response.Username = request.Username; |
|
|
response.Token = await _tokenClaimsService.GetTokenAsync(request.Username); |
|
|
|
|
|
|
|
|
if (result.Succeeded) |
|
|
|
|
|
{ |
|
|
|
|
|
response.Token = await _tokenClaimsService.GetTokenAsync(request.Username); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return response; |
|
|
return response; |
|
|
} |
|
|
} |
|
|
|
|
|
@ -24,6 +24,7 @@ namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers |
|
|
[Theory] |
|
|
[Theory] |
|
|
[InlineData("demouser@microsoft.com", AuthorizationConstants.DEFAULT_PASSWORD, true)] |
|
|
[InlineData("demouser@microsoft.com", AuthorizationConstants.DEFAULT_PASSWORD, true)] |
|
|
[InlineData("demouser@microsoft.com", "badpassword", false)] |
|
|
[InlineData("demouser@microsoft.com", "badpassword", false)] |
|
|
|
|
|
[InlineData("baduser@microsoft.com", "badpassword", false)] |
|
|
public async Task ReturnsExpectedResultGivenCredentials(string testUsername, string testPassword, bool expectedResult) |
|
|
public async Task ReturnsExpectedResultGivenCredentials(string testUsername, string testPassword, bool expectedResult) |
|
|
{ |
|
|
{ |
|
|
var request = new AuthenticateRequest() |
|
|
var request = new AuthenticateRequest() |
|
|
|