আমি সম্প্রতি Asp.Net Identity Coreআমার অ্যাপ্লিকেশন ফর্মটি 1.0 থেকে 2.0 তে আপডেট করেছি।
এখানে নতুন বৈশিষ্ট্য রয়েছে যা আমি পছন্দ করতে চাইছিলাম GenerateEmailConfirmationTokenইত্যাদি
আমি এই প্রকল্পটি একটি রেফারেন্স হিসাবে ব্যবহার করছি ।
যখন ব্যবহারকারী নিবন্ধন করার চেষ্টা করে, তখন আমি রেজিস্টরের পোস্ট পদ্ধতি কার্যকর করার সময় ত্রুটি পাই
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.
আপাতত, আমি কেবল দেখতে চেয়েছিলাম এটি কী ধরণের কোড উত্পন্ন করে। আমার ApplicationUserক্লাসে কিছু পরিবর্তন করার দরকার আছে যা ক্লাস থেকে উত্তরাধিকার সূত্রে প্রাপ্ত হয় IdentityUser?
বা এই ফাংশনটির কাজ পেতে আমার কিছু পরিবর্তন করার দরকার আছে?