authentication fix
parent
5b2b5bbab9
commit
5b6da4d1d5
|
@ -16,8 +16,8 @@ namespace IdentityServer.Api.Controllers
|
||||||
_mediator = mediator;
|
_mediator = mediator;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("authenticate/{userName}/{password}")]
|
[HttpPost("authenticate")]
|
||||||
public async Task<IActionResult> AuthenticateUser([FromRoute] AuthenticateUser authenticateUser)
|
public async Task<IActionResult> AuthenticateUser([FromQuery] AuthenticateUser authenticateUser)
|
||||||
{
|
{
|
||||||
var result = await _mediator.Send(authenticateUser);
|
var result = await _mediator.Send(authenticateUser);
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ namespace IdentityServer.Api.Controllers
|
||||||
return BadRequest();
|
return BadRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("authorize/{token}")]
|
[HttpPost("authorize")]
|
||||||
public async Task<IActionResult> AuthorizeToken([FromRoute] AuthorizeToken authorizeToken)
|
public async Task<IActionResult> AuthorizeToken([FromQuery] AuthorizeToken authorizeToken)
|
||||||
{
|
{
|
||||||
var result = await _mediator.Send(authorizeToken);
|
var result = await _mediator.Send(authorizeToken);
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,5 @@ namespace IdentityServer.Application.Commands
|
||||||
{
|
{
|
||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
|
||||||
public AuthenticateUser(string userName, string password)
|
|
||||||
{
|
|
||||||
UserName = userName;
|
|
||||||
Password = password;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,12 @@ namespace IdentityServer.Application.Stores
|
||||||
|
|
||||||
public TokenValidation ValidateToken(string token)
|
public TokenValidation ValidateToken(string token)
|
||||||
{
|
{
|
||||||
var lastIndexOfSeparator = token.LastIndexOf('-') + 1;
|
var lastIndexOfSeparator = token.LastIndexOf('-');
|
||||||
var userIdString = token.Substring(lastIndexOfSeparator, token.Length - lastIndexOfSeparator);
|
if (lastIndexOfSeparator == -1)
|
||||||
|
return InvalidToken;
|
||||||
|
|
||||||
|
var indexOfNextCharacterAfterSeparator = lastIndexOfSeparator + 1;
|
||||||
|
var userIdString = token.Substring(indexOfNextCharacterAfterSeparator, token.Length - indexOfNextCharacterAfterSeparator);
|
||||||
|
|
||||||
if (!int.TryParse(userIdString, out int userId))
|
if (!int.TryParse(userIdString, out int userId))
|
||||||
return InvalidToken;
|
return InvalidToken;
|
||||||
|
|
Loading…
Reference in New Issue