【问题标题】:Invalid token error in reset password in asp.net 5 rc 1 after moving to new server移动到新服务器后,在 asp.net 5 rc 1 中重置密码时出现无效令牌错误
【发布时间】:2016-04-19 20:02:06
【问题描述】:

我们在生产级别使用 asp.net 5 rc1 和 asp.net Identity。

一段时间后,由于某些原因,我们搬到了新服务器。现在我们的用户不能使用“忘记密码”选项了!在重置密码页面填写字段后,userManager.ResetPasswordAsync 抛出“Invalid Token”错误。

这是ResetPassword 方法:

    [HttpPost]
    [AllowAnonymous]
    public async Task<IActionResult> ResetPassword(ResetPasswordViewModel model)
    {
        if (!ModelState.IsValid)
        {
            return View(model);
        }
        var user = await _userManager.FindByEmailAsync(model.Email);

        var result = await _userManager.ResetPasswordAsync(user, model.Code, model.Password);
        if (result.Succeeded)
        {
            return RedirectToAction(nameof(AccountController.ResetPasswordConfirmation), "Account");
        }
        AddErrors(result);
        return View();
    }

在新服务器上注册的新用户使用忘记密码没有问题。 我认为这个问题应该与用户的ConcurrencyStampSecurityStamp 属性有关。也许它们在新机器上无效。

有什么想法吗?

【问题讨论】:

  • 你说你在一个新的服务器上。你还在运行旧的服务器和负载平衡吗?还是之前的机器上生成的令牌?
  • @blowdart 旧服务器已停止。我们只在新服务器上运行
  • 你的 web.config 中有 machineKey 吗?
  • @trailmax 不,我们没有。

标签: asp.net-identity asp.net-core


【解决方案1】:

我猜对了。问题来自SecurityStamp。我更新了UserManager.UpdateSecurityStampAsync的所有SecurityStamps,现在老用户也可以毫无问题地使用忘记密码了。

【讨论】:

    猜你喜欢
    • 2015-05-29
    • 2019-04-11
    • 2018-09-30
    • 2019-05-18
    • 2017-08-12
    • 2017-06-02
    • 1970-01-01
    • 2016-05-03
    • 2015-04-28
    相关资源
    最近更新 更多