// GET: /member/ChangePassword public virtual ActionResult ChangePassword(string issuedKey) { ActionResult returnValue = null; ProviderCurrentMember currentMember = ProviderCurrentMember.Instance; if (!string.IsNullOrWhiteSpace(issuedKey)) { ProviderIssuedKey aKey = new ProviderIssuedKey(); if (!aKey.Load(issuedKey)) { MessageVM returnMessageVM = new MessageVM { Image = ImageLibrary.Alert, CssClassContainer = "failure", Message = "Invalid key provided. Please <a href=\"" + Url.Action(MVC.Info.ContactUs()) + "\">contact us</a> to resolve the issue.", Title = "Login failure", LinkText = "Continue", LinkHref = Url.Action(MVC.Home.Index()) }; returnValue = View(MVC.Shared.Views.Message, returnMessageVM); } else { // validate the e-mail if it wasn't already. ProviderEmail anEmail = new ProviderEmail(); if (anEmail.Load(aKey.Data) && !anEmail.IsValidated) { anEmail.IsValidated = true; anEmail.EditDate = DateTime.UtcNow; anEmail.Save(); } List<string> errorList = new List<string>(); if (currentMember.Login(issuedKey, null, false, ref errorList) == ProviderCurrentMember.LoginEnum.success) { MessageVM returnMessageVM = new MessageVM { Image = ImageLibrary.Alert, CssClassContainer = "failure", Message = "Failed to login. Please <a href=\"" + Url.Action(MVC.Info.ContactUs()) + "\">contact us</a> to resolve the issue.", Title = "Login failure", LinkText = "Continue", LinkHref = Url.Action(MVC.Home.Index()), Details = errorList }; returnValue = View(MVC.Shared.Views.Message, returnMessageVM); } } } if(currentMember.IsLoggedOn) { ChangePasswordVM viewModel = new ChangePasswordVM { CurrentMemberId = currentMember.Id.Value }; returnValue = View(viewModel); } return returnValue; }
public virtual ActionResult ChangePassword(string issuedKey, ChangePasswordVM model) { ActionResult returnValue = null; ProviderCurrentMember currentMember = ProviderCurrentMember.Instance; if (ModelState.IsValid) { try { bool previousActiveState = currentMember.IsActive; currentMember.Password = model.Password; currentMember.EditDate = DateTime.UtcNow; currentMember.Save(); // if this just activated someone then send them to the completion page if (currentMember.IsActive && previousActiveState != currentMember.IsActive) { returnValue = RedirectToAction(MVC.Member.RegisterComplete()); } else { returnValue = RedirectToAction(MVC.Member.ChangePasswordComplete()); } } catch (Exception caughtException) { InsideWordWebLog.Instance.Log.Error(caughtException); ModelState.AddModelError("", "Failed to change password. An administrator will contact you through e-mail regarding this issue."); } } if (returnValue == null) { returnValue = View(model); } return returnValue; }