in UnicornStore/Controllers/AccountController.cs [147:179]
public async Task<IActionResult> Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
_logger.LogInformation("User {userName} was created.", model.Email);
//Bug: Remember browser option missing?
//Uncomment this and comment the later part if account verification is not needed.
//await SignInManager.SignInAsync(user, isPersistent: false);
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
// Send an email with this link
string code = await UserManager.GenerateEmailConfirmationTokenAsync(user);
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme);
await MessageServices.SendEmailAsync(model.Email, "Confirm your account",
"Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");
#if !DEMO
return RedirectToAction("Index", "Home");
#else
//To display the email link in a friendly page instead of sending email
ViewBag.Link = callbackUrl;
return View("DemoLinkDisplay");
#endif
}
AddErrors(result);
}
// If we got this far, something failed, redisplay form
return View(model);
}