Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have added a project called WebCustomUser to <a href="https://github.com/onybo/Asp.Net-Identity-RC1-sample-app/tree/master/WebApplication" rel="nofollow">https://github.com/onybo/Asp.Net-Identity-RC1-sample-app/tree/master/WebApplication</a>.</p> <p>This project demonstrates use of the methods: </p> <ul> <li>RequireTokenConfirmationForSignInAsync</li> <li>ConfirmSignInTokenAsync</li> </ul> <p>to implement token activation of user accounts. </p> <p>Update: The project now include a custom entity framework model with custom users which have an email address added (just as an example).</p> <p>The modeling project that contains two diagrams that shows some of the new classes in ASP.NET identity is now in a separate solution so that the main solution can be opened in the profession SKU.</p> <p>Heres the modified Register action and the Activate action.</p> <pre><code> [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task&lt;ActionResult&gt; Register(RegisterViewModel model) { if (ModelState.IsValid) { // Create a profile, password, and link the local login before signing in the user User user = new User(model.UserName); var result = await new UserManager(IdentityManager).CreateLocalUserAsync(user, model.Password); if (result.Success) { var token = Guid.NewGuid(); var tokenResult = await AuthenticationManager.RequireTokenConfirmationForSignInAsync(token.ToString(), user.Id, DateTime.Now.AddDays(2)); if (tokenResult.Success) { return RedirectToAction("Registered", "Account", new { userId = user.Id.ToString(), token = token.ToString() }); } else AddModelError(tokenResult, "RequireTokenConfirmation failed"); } else { AddModelError(result, "Failed to register user name: " + model.UserName); } } // If we got this far, something failed, redisplay form return View(model); } [AllowAnonymous] public async Task&lt;ActionResult&gt; Activate(string userId, string token) { var tokenResult = await AuthenticationManager.ConfirmSignInTokenAsync(token); return RedirectToAction("Login", new {returnUrl="/home"}); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload