So, I'm trying to change user password using default ASP.NET methond, but just don't work, somehow I'm not able to get the current user data. I tried different approaches to get userId and still nothing. And I didn't change a thing except for the [AllowAnonymous], because there was a error saying permission denied when I tried to call the method.
// POST api/Account/ChangePassword
[AllowAnonymous]
[Route("ChangePassword")]
public async Task<IHttpActionResult> ChangePassword(ChangePasswordBindingModel model)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
IdentityResult result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword,
model.NewPassword);
if (!result.Succeeded)
{
return GetErrorResult(result);
}
return Ok();
}
So, I found the answer... I forgot to put this on the request:
authorization: bearer my_token