本文整理汇总了C#中UserManager.ConfirmEmail方法的典型用法代码示例。如果您正苦于以下问题:C# UserManager.ConfirmEmail方法的具体用法?C# UserManager.ConfirmEmail怎么用?C# UserManager.ConfirmEmail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager.ConfirmEmail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfirmEmail
public ActionResult ConfirmEmail(string userID, string code)
{
var userStore = new UserStore<IdentityUser>();
UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
var user = manager.FindById(userID);
CreateTokenProvider(manager, EMAIL_CONFIRMATION);
try
{
IdentityResult result = manager.ConfirmEmail(userID, code);
if (result.Succeeded)
{
TempData["ConfirmationResponse"] = "You have successfully registered for an account. Please verify your account by clicking on the link sent to you in your e-mail.";
return RedirectToAction("Login");
}
else
{
TempData["ConfirmationResponseError"] = "Your validation attempt has failed. We may be experiencing system problems. Please try again later.";
return RedirectToAction("Login");
}
}
catch
{
TempData["ConfirmationResponseError"] = "Your validation attempt has failed. We may be experiencing system problems. Please try again later.";
return RedirectToAction("Login");
}
}
示例2: ConfirmEmail
public ActionResult ConfirmEmail(string userID, string code)
{
var userStore = new UserStore<IdentityUser>();
UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
var user = manager.FindById(userID);
CreateTokenProvider(manager, EMAIL_CONFIRMATION);
try
{
IdentityResult result = manager.ConfirmEmail(userID, code);
if (result.Succeeded)
ViewBag.Message = "You are now registered!";
}
catch
{
ViewBag.Message = "Validation attempt failed!";
}
return View();
}
示例3: ConfirmEmail
public ActionResult ConfirmEmail(string userId, string code)
{
var userStore = new UserStore<IdentityUser>();
UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
var user = manager.FindById(userId);
CreateTokenProvider(manager, EMAIL_CONFIRMATION);
try
{
IdentityResult result = manager.ConfirmEmail(userId, code);
if (result.Succeeded)
{
IAuthenticationManager authenticationManager
= HttpContext.GetOwinContext().Authentication;
authenticationManager
.SignOut(DefaultAuthenticationTypes.ExternalCookie);
var identity = new ClaimsIdentity(new[] {
new Claim(ClaimTypes.Name, user.UserName),
},
DefaultAuthenticationTypes.ApplicationCookie,
ClaimTypes.Name, ClaimTypes.Role);
// SignIn() accepts ClaimsIdentity and issues logged in cookie.
authenticationManager.SignIn(new AuthenticationProperties
{
IsPersistent = false
}, identity);
ViewBag.UserName = user.UserName;
ViewBag.Message = "You are now registered!";
}
}
catch
{
ViewBag.Message = "Validation attempt failed!";
}
return View();
}