您不需要密码来验证 Identity 中的用户。只需要根据令牌找到相关用户。考虑这个简单的例子:
public ActionResult UrlAuth(string token)
{
var userManager=HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
// imaging you have a custom token manager which return userID form token
string userID=_tokenManager.GetUserIDByToken(token);
var user = userManager.FindById(userID);
if (user != null)
{
var ident = userManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);
HttpContext.GetOwinContext().Authentication.SignIn(new AuthenticationProperties { IsPersistent = false }, ident);
// authentication succeed do what you want
return Redirect("Wherever");
}
ModelState.AddModelError("", "Invalid username or password");
return View();
}