Skip to content

Instantly share code, notes, and snippets.

@Mirch
Last active September 30, 2018 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mirch/680a6d717ce6d5cd73e7a448e083208b to your computer and use it in GitHub Desktop.
Save Mirch/680a6d717ce6d5cd73e7a448e083208b to your computer and use it in GitHub Desktop.
[HttpGet]
public IActionResult Register()
{
return View();
}
[HttpPost]
public async Task<IActionResult> Register(UserRegisterModel model)
{
var exists = _db.Users.SingleOrDefault(u => u.Email.Equals(model.Username));
if (exists != null)
return View();
var result = await _userManager.CreateAsync(new IdentityUser(model.Username), model.Password);
if (result.Succeeded)
return RedirectToAction("Index", "Home");
return View();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment