public async Task<ActionResult> Register(RegisterModel model) { if (!ModelState.IsValid) { return View(); } var user = new Member { UserName = model.UserName, Email = model.Email }; var result = await userManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignIn(user); return Redirect(GetRedirectUrl(model.ReturnURL)); } foreach (var error in result.Errors) { ModelState.AddModelError("", error); } return View(); }
private async Task SignIn(Member user) { var identity = await userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie); GetAuthenticationManager().SignIn(identity); }