public ActionResult SendPasswordEmail(string nameOrEmail) { var result = ServiceProxySingleton.Instance.CreateTemporaryCode(nameOrEmail); if (result.IsError()) return Json(result); var helper = new EmailController("ChangePasswordEmail", result.AttachedObject); helper.SendPasswordEmail(); TempData["SuccessMessage"] = Messages.EmailSentPasswordReset; return new EmptyResult(); }
public ActionResult Register(RegisterUser user) { if (ModelState.IsValid) { user.Password = CryptHelper.GetSha512Base64Hash(user.Login.ToLower() + user.Password); var result = ServiceProxySingleton.Instance.RegisterUser(user); if (result.IsError()) ModelState.AddModelError("", result.ErrorMessage); else { user.RegistrationCode = result.AttachedObject; var helper = new EmailController("ConfirmEmail", new PasswordMailInfo {UserName = user.UserFio ?? user.Login, Email = user.Email, Code = user.RegistrationCode}); helper.SendConfirmEmail(); ViewBag.Success = true; } } else { var errors = ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage).Distinct().ToArray(); foreach (var e in errors) ModelState.AddModelError("", e); } return View(user); }