Asp.Net Identity Core
版本。新版本有一些我想尝试的新功能,例如GenerateEmailConfirmationToken
等。我参考了这个项目。当用户试图注册时,在注册的Post方法执行过程中出现了错误。private readonly UserManager<ApplicationUser> _userManager;
public ActionResult Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var ifUserEXists = _userManager.FindByName(model.EmailId);
if (ifUserEXists == null) return View(model);
var confirmationToken = _userRepository.CreateConfirmationToken();//this is how i'm generating token currently.
var result = _userRepository.CreateUser(model,confirmationToken);
var user = _userManager.FindByName(model.EmailId);
if (result)
{
var code = _userManager.GenerateEmailConfirmationToken(user.Id);//error here
_userRepository.SendEmailConfirmation(model.EmailId, model.FirstName, confirmationToken);
//Information("An email is sent to your email address. Please follow the link to activate your account.");
return View("~/Views/Account/Thank_You_For_Registering.cshtml");
}
}
//Error("Sorry! email address already exists. Please try again with different email id.");
ModelState.AddModelError(string.Empty, Resource.AccountController_Register_Sorry__User_already_exists__please_try_again_);
return View(model);
}
在这条线上
var code = _userManager.GenerateEmailConfirmationToken(user.Id);
我收到了错误提示:
No IUserTokenProvider is registered.
现在,我只是想看看它生成什么样的代码。
我需要对继承自IdentityUser
类的ApplicationUser
类做一些更改吗?
或者说,我需要做一些更改以使这些函数正常工作吗?