public async Task <ActionResult> Registration(RegisteViewModel registerData) { if (ModelState.IsValid) { if (repo.CheckEmailUniqueness(registerData.Email) == false) { ModelState.AddModelError("", @Resources.Web.MailBusy); return(PartialView(registerData)); } string key = CollectionOfMethods.GetHashString(registerData.Email) + CollectionOfMethods.GetHashString(registerData.Name); UserForConfirmedEmail newUser = new UserForConfirmedEmail() { Key = key, Email = registerData.Email, User = new User() { Name = registerData.Name, PasswordHash = CollectionOfMethods.GetHashString(registerData.Password), Email = registerData.Email, Date = DateTime.UtcNow, Confirmed = false } }; repoForEmail.Save(newUser); EmailService emailService = new EmailService(); await emailService.SendEmailAsync(registerData.Email, @Resources.Web.ConfirmEmailTheme, TemplateForEmail.Registration(Url.Action("ConfirmEmail", "Account", new { Key = key }, Request.Url.Scheme))); return(Json(new { successful = true })); // return View("WaitingForConfirm"); } return(PartialView(registerData)); }
public ActionResult ConfirmEmail(string key) { UserForConfirmedEmail user = repoForEmail.CheckKey(key); string message = Resources.Web.WaitingForPasswordConfirmation; if (user != null) { repoForEmail.SetUserConfirmed(user.UserId); message = @Resources.Web.RegistrationSuccesfull; repoForEmail.DeleteKey(user.Id); FormsAuthentication.SetAuthCookie(user.Email, true); } ViewBag.message = message; return(View()); }