public ActionResult ChangePassword(IChangePasswordModel model) { if (ModelState.IsValid) { // ChangePassword will throw an exception rather // than return false in certain failure scenarios. bool changePasswordSucceeded; try { var currentUser = Membership.GetUser(User.Identity.Name, userIsOnline: true); changePasswordSucceeded = currentUser.ChangePassword(model.OldPassword, model.NewPassword); } catch (Exception) { changePasswordSucceeded = false; } if (changePasswordSucceeded) { return RedirectToAction("ChangePasswordSuccess"); } else { ModelState.AddModelError("", "The current password is incorrect or the new password is invalid."); } } // If we got this far, something failed, redisplay form return View(model); }
public ChangePasswordViewModel( IChangePasswordModel changePasswordModel, IPasswordValidator passwordValidator, INavigationManager navigation) : base(navigation) { this.changePasswordModel = changePasswordModel ?? throw new ArgumentNullException(nameof(changePasswordModel)); this.passwordValidator = passwordValidator ?? throw new ArgumentNullException(nameof(passwordValidator)); OnPasswordUpdated(); }
private ModelFactory() { _tcApi = new TCApi(); _logInModel = new LogInModel(_tcApi); _homeModel = new HomeModel(_tcApi); _userPreference = new UserPreference(_tcApi); _settingsModel = new SettingsModel(); _createUserModel = new CreateUserModel(_tcApi); _createCaseModel = new CreateCaseModel(_tcApi); _caseModel = new CaseModel(_tcApi); _changePasswordModel = new ChangePasswordModel(_tcApi); _mapModel = new MapModel(_tcApi); _trafficLightModel = new TrafficLightOverviewModel(_tcApi); }
public void Init() { _fakeView = Substitute.For <IChangePasswordView>(); _fakeModel = Substitute.For <IChangePasswordModel>(); _uut = new ChangePasswordPresenter(_fakeView, _fakeModel); }
public ChangePasswordPresenter(IChangePasswordView view, IChangePasswordModel model) { _view = view; _model = model; }