public async Task <ActionResult> Register(RegisterViewModel model, string returnUrl) { Invitation invite = Identity.AcceptedInvitation(model.UserName, model.Email); if (invite == null) { ViewBag.Warning = "Registration failed. You must be invited to register for OPIDDaily and must register using the user name and email you supplied the Site Administrator when you were invited."; return(View("Warning")); } if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.UserName, Email = model.Email, AgencyId = invite.AgencyId }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://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>"); // Assign Role to user here await this.UserManager.AddToRoleAsync(user.Id, invite.Role); // Log.Info("Redirect to Users.Index"); return(RedirectToAction("Index", "Users")); } AddErrors(result); } // If we got this far then something failed, so redisplay the form return(View(model)); }