Last active
March 15, 2017 19:32
-
-
Save sabbour/9950b96a1685ddedec40 to your computer and use it in GitHub Desktop.
Augmenting the Register method to pass on the Country Code, PIN and Phone number to the Application User
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// POST: /Account/Register | |
[HttpPost] | |
[AllowAnonymous] | |
[ValidateAntiForgeryToken] | |
public async Task<ActionResult> Register(RegisterViewModel model) | |
{ | |
if (ModelState.IsValid) | |
{ | |
var user = new ApplicationUser() { UserName = model.Email, Email = model.Email, CountryCode = mode.CountryCode, PIN = model.PIN, Phone = model.Phone }; | |
IdentityResult result = await UserManager.CreateAsync(user, model.Password); | |
if (result.Succeeded) | |
{ | |
await 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.Id); | |
// var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); | |
// await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); | |
return RedirectToAction("Index", "Home"); | |
} | |
else | |
{ | |
AddErrors(result); | |
} | |
} | |
// If we got this far, something failed, redisplay form | |
return View(model); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment