public ActionResult ChangePassword(ChangePasswordView view) { try { if (!ModelState.IsValid) { StringBuilder builder = new StringBuilder(); foreach (ModelError error in ModelState.Values.SelectMany(v => v.Errors)) { builder.AppendLine(error.ErrorMessage); } throw new ApplicationException(builder.ToString()); } using (ITransaction trans = DbSession.BeginTransaction()) { GetEntity <User>(view.Id).Password = Helpers.CreateMD5Hash(view.Password); trans.Commit(); return(SuccessJson()); } } catch (Exception e) { return(FailedJson(e.Message)); } }
public IActionResult ChangePassword([FromBody] ChangePasswordView login) { UserModels sv = new UserModels(); IActionResult response = null; var identity = (ClaimsIdentity)User.Identity; IEnumerable <Claim> claims = identity.Claims; var userLogin = claims.FirstOrDefault(c => c.Type == ClaimTypes.Email).Value; if (!string.IsNullOrEmpty(login.Password) && !string.IsNullOrEmpty(login.ConfirmPassword)) { // user change password User user = sv.GetUserbyUserName(userLogin); if (user != null && MD5Extend.EncodePassword(login.OldPassword) == user.Password) { if (login.Password == login.ConfirmPassword) { user.Password = MD5Extend.EncodePassword(login.Password); sv.UpdateUserPassword(user); response = Json(new { code = Constant.Success, message = Constant.MessageUpdateCompleted }); } else { response = Json(new { code = Constant.Fail, message = Constant.MessageConfirmPassword }); } } } else { response = Json(new { code = Constant.NotExist, message = Constant.MessageNotExist }); } return(response); }
public async Task <IActionResult> ForgotPassword(ChangePasswordView model) { if (ModelState.IsValid) { var user = await userManager.FindByEmailAsync(model.Email); if (user == null) { ViewBag.Message = errorMessage.ReturnErrorMessage("ErrorMessages", "UserIsNotFounded"); return(View("ErrorPage")); } ViewBag.UserIsNull = false; var customer = unitOfWork.Customers.GetAll().Where(c => c.Email == model.Email).First(); var code = await userManager.GeneratePasswordResetTokenAsync(user); var callbackUrl = Url.Action("ChangePassword", "Account", new { userId = user.Id, code }, protocol: HttpContext.Request.Scheme); EmailSender emailSender = new EmailSender(); await emailSender.PasswordChangeCodeSend(customer, callbackUrl); return(View("ForgotPasswordInfo")); } return(View(model)); }
public ActionResult ChangePassword(string Tip) { ChangePasswordView cpv = new ChangePasswordView(); ViewBag.Tip = Tip; return(View(cpv)); }
private void btnChangePassword_Click(object sender, RoutedEventArgs e) { ChangePasswordView cp = new ChangePasswordView("CUSTOMER", Session.User["ID"].ToString()); cp.ShowDialog(); this.Show(); }
public async Task <IActionResult> ChangePassword(ChangePasswordView model) { if (!ModelState.IsValid) { return(View(model)); } var user = await userManager.FindByNameAsync(model.Email); if (user == null) { ViewBag.Message = errorMessage.ReturnErrorMessage("ErrorMessages", "UserIsNotFounded"); return(View("ErrorPage")); } var result = await userManager.ResetPasswordAsync(user, model.Code, model.Password); if (result.Succeeded) { return(RedirectToAction("Index", "Home")); } return(View(model)); }
public void ChangePassword(ChangePasswordView model) { try { string md5SaltPassword = Config.Md5Salt(model.Password); var account = Read(x => x.Email.Equals(_principal.Email, StringComparison.InvariantCultureIgnoreCase) && x.Password == md5SaltPassword); //判斷是否存在 if (account == null) { ValidationDictionary.AddGeneralError("Account ID or password error"); } else { account.Password = Config.Md5Salt(model.newPassword); account.ModDate = System.DateTime.Now; Save(); } } catch (Exception ex) { ValidationDictionary.AddGeneralError(ex.Message); } }
public ActionResult ChangePasswordPage(ChangePasswordView changePasswordView) { if (changePasswordView == null) { throw new ArgumentNullException(nameof(changePasswordView)); } if (!ModelState.IsValid) { var viewModel = this.accountService.GetChangePasswordPage(changePasswordView, string.Empty); return(this.View("ChangePasswordPage", viewModel)); } var message = accountService.ProcessChangePasswordPage(changePasswordView); if (!string.IsNullOrEmpty(message)) { var viewModel = this.accountService.GetChangePasswordPage(changePasswordView, message); return(this.View("ChangePasswordPage", viewModel)); } message = string.Format("{0} has successfully change password", changePasswordView.Email); return(this.RedirectToAction("Login", new { infoMessage = message })); }
public ActionResult ChangePasswordConfirmed(ChangePasswordView changePasswordViewModel) { if (ModelState.IsValid) { User user = new User(); user = userService.GetById(changePasswordViewModel.UserId); string oldPassword = changePasswordViewModel.OldPassword; string oldPasswordHash = GetHashedPassword(oldPassword + user.UserName); if (oldPasswordHash == user.Password) { user.Password = GetHashedPassword(userPassword: changePasswordViewModel.ConfirmPassword + user.UserName); userService.Update(user); return(RedirectToAction("ViewUsers")); } else { changePasswordViewModel.SubmissionMessage = "Password wrong! Enter Correct password"; return(View("ChangePassWord", changePasswordViewModel)); } } else { return(View("ChangePassWord", changePasswordViewModel)); } }
public ActionResult ChangePassword(string id) { ChangePasswordView ChangePasswordView = new ChangePasswordView(); ChangePasswordView.Username = id; return(View(ChangePasswordView)); }
public ActionResult ChangePassword(ChangePasswordView ChangeData) { if (ModelState.IsValid) { ViewData["ChangeState"] = memberService.ChangePassword(User.Identity.Name, ChangeData.Password, ChangeData.NewPassword); } return(View()); }
public void showChangePasswordView(ChangePasswordView _changePasswordView) { dashboardView.panelContent.Controls.Clear(); _changePasswordView.TopLevel = false; _changePasswordView.TopMost = true; dashboardView.panelContent.Controls.Add(_changePasswordView); _changePasswordView.Show(); }
/// <summary> /// Changes the password. /// </summary> /// <returns></returns> public IChangePasswordView ChangePassword() { var view = new ChangePasswordView { }; return(view); }
public async void ChangePassword() { var changePasswordPage = new ChangePasswordView(); ChangePasswordViewModel vm = new ChangePasswordViewModel(Infor.Password); changePasswordPage.BindingContext = vm; await App.Current.MainPage.Navigation.PushAsync(changePasswordPage, true); }
private void OpenChangePasswordView(object obj) { var view = new ChangePasswordView(); ChangePasswordViewModel vm = new ChangePasswordViewModel(this); view.DataContext = vm; SelectedView = view; }
public override void RunTest() { client = new TestClient(); client.RegisterProfile(); client.Login(); //doing some work that is permission required client.Profile_GetMine(); //changing password via invalid old password var passwordChangeView = new ChangePasswordView() { NewPassword = "******", OldPassword = "******" }; bool invalidPasswordError = false; try { client.Profiles_changeMyPassword(passwordChangeView); }catch (AppException exc) { if (exc.ErrorCode.Equals(ErrorConstants.PROFILE_PASSWORD_INVALID)) { invalidPasswordError = true; } } if (!invalidPasswordError) { throw new Exception("providing invalid old password during password change should be prevented"); } Log("change password having invalid old password is being prevented."); //changing password via corrent old password passwordChangeView = new ChangePasswordView() { NewPassword = "******", OldPassword = client.Profile.Password }; client.Profiles_changeMyPassword(passwordChangeView); client.Profile.Password = passwordChangeView.NewPassword; //doing somthing with the old tocken client.Profile_GetMine(); Log("after change password the old tocken is still valid."); //doing somthing with new password client.Logout(); client.Login(); //TODO //client.Order_mylist(); Log("password changed is working properly"); //unregistering profile client.UnregisterProfile(); client.Logout(); }
public override void LoadingEnd() { view = CreateView <ChangePasswordView>(); view.AddEvent(model.CheckId, model.CheckPassword, model.CheckChangePassword, model.CheckPin); view.Show(); }
public ActionResult ChangePassWord(int id) { ChangePasswordView changePasswordViewModel = new ChangePasswordView { UserId = id }; return(View(changePasswordViewModel)); }
public ActionResult ChangePassword() { var changePasswordView = new ChangePasswordView { ID = CurrentUser.ID }; return(View(changePasswordView)); }
/// <summary> /// Creates the change password view. /// </summary> /// <returns></returns> public IChangePasswordView CreateChangePasswordView() { var result = new ChangePasswordView { ProcessingMessage = string.Empty }; return(result); }
public async Task <string> UbahPass(ChangePasswordView changePass) { var userIdentity = await _userManager.FindByNameAsync(changePass.Username); await _userManager.ChangePasswordAsync(userIdentity, changePass.Password, changePass.NewPassword); return($"Password berhasil di ubah"); }
/// <summary> /// Creates the change password page view. /// </summary> /// <param name="processingMessage">The processing message.</param> /// <returns></returns> public IChangePasswordView CreateChangePasswordPageView(string processingMessage) { var view = new ChangePasswordView { ProcessingMessage = processingMessage }; return(view); }
public ActionResult ChangePassword(ChangePasswordView data) { var cookies = Request.Cookies[FormsAuthentication.FormsCookieName]; var tickets = FormsAuthentication.Decrypt(cookies.Value); string role = tickets.UserData; TempData["UpdateDataResult"] = portalDBService.ChangePassword(role, data.Password, data.NewPassword); return(RedirectToAction("UpdateMemberDataResult", "MyAccount")); }
public IActionResult ValidateChangePassword([FromBody] ChangePasswordView passwordView) { IActionResult response = null; UserModels userModels = new UserModels(); User user = new User(); var mess = string.Empty; string rt = string.Empty; bool is_valid = true; if (string.IsNullOrEmpty(passwordView.OldPassword)) { is_valid = false; if (mess == string.Empty) { mess = Constant.MessageDataEmpty; response = Json(new { code = Constant.Empty, message = mess, field = "oldPassword" }); } } if (string.IsNullOrEmpty(passwordView.Password)) { is_valid = false; if (mess == string.Empty) { mess = Constant.MessageDataEmpty; response = Json(new { code = Constant.Empty, message = mess, field = "password" }); } } if (string.IsNullOrEmpty(passwordView.ConfirmPassword)) { is_valid = false; if (mess == string.Empty) { mess = Constant.MessageDataEmpty; response = Json(new { code = Constant.Empty, message = mess, field = "confirmPassword" }); } } if (passwordView.Password != passwordView.ConfirmPassword) { is_valid = false; if (mess == string.Empty) { mess = Constant.MessageConfirmPassword; response = Json(new { code = Constant.Fail, message = mess, field = "confirmPassword" }); } } if (is_valid) { response = Json(new { code = Constant.Success, message = Constant.MessageOk }); } return(response); }
void ReleaseDesignerOutlets() { if (borderConfirmPassword != null) { borderConfirmPassword.Dispose(); borderConfirmPassword = null; } if (borderNewPassword != null) { borderNewPassword.Dispose(); borderNewPassword = null; } if (btnBack != null) { btnBack.Dispose(); btnBack = null; } if (btnSavePassword != null) { btnSavePassword.Dispose(); btnSavePassword = null; } if (ChangePasswordView != null) { ChangePasswordView.Dispose(); ChangePasswordView = null; } if (lblChangePassword != null) { lblChangePassword.Dispose(); lblChangePassword = null; } if (lblDescript != null) { lblDescript.Dispose(); lblDescript = null; } if (txtConfirmPassword != null) { txtConfirmPassword.Dispose(); txtConfirmPassword = null; } if (txtNewPassword != null) { txtNewPassword.Dispose(); txtNewPassword = null; } }
public ActionResult ChangePassword(ChangePasswordView changePasswordView) { if (ModelState.IsValid) { CurrentUser.Password = changePasswordView.NewPassword; Repository.ChangePassword(CurrentUser); TempData["message"] = "Saved"; } return(View(changePasswordView)); }
/// <summary> /// Проверяет, необходима ли смена пароля для текущего пользователя, и, если необходима, открывает диалог смены пароля /// </summary> /// <returns> /// <para><b>True</b> - Если смена пароля не нужна или пароль был успешно изменён</para> /// <b>False</b> - Если смена была затребована смена пароля, но пароль не был изменён /// </returns> /// <exception cref="InvalidOperationException">Если текущий пользователь null</exception> private static bool ChangePassword(IApplicationConfigurator applicationConfigurator) { ResponseType result; int currentUserId; IChangePasswordModel changePasswordModel; using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) { var userRepository = new UserRepository(); var currentUser = userRepository.GetCurrentUser(uow); if (currentUser is null) { throw new InvalidOperationException("CurrentUser is null"); } if (!currentUser.NeedPasswordChange) { return(true); } currentUserId = currentUser.Id; if (!(Connection.ConnectionDB is MySqlConnection mySqlConnection)) { throw new InvalidOperationException($"Текущее подключение не является {nameof(MySqlConnection)}"); } var mySqlPasswordRepository = new MySqlPasswordRepository(); changePasswordModel = new MysqlChangePasswordModelExtended(applicationConfigurator, mySqlConnection, mySqlPasswordRepository); var changePasswordViewModel = new ChangePasswordViewModel( changePasswordModel, passwordValidator, null ); var changePasswordView = new ChangePasswordView(changePasswordViewModel) { Title = "Требуется сменить пароль" }; changePasswordView.ShowAll(); result = (ResponseType)changePasswordView.Run(); changePasswordView.Destroy(); } if (result == ResponseType.Ok && changePasswordModel.PasswordWasChanged) { using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) { var user = uow.GetById <User>(currentUserId); user.NeedPasswordChange = false; uow.Save(user); uow.Commit(); return(true); } } QSSaaS.Session.StopSessionRefresh(); ClearTempDir(); return(false); }
public async Task <IdentityResult> ChangePassword(ChangePasswordView model) { var user = await _userManager.FindByEmailAsync(model.Email); bool isCorrectPassword = await _userManager.CheckPasswordAsync(user, model.CurrentPassword); var token = await _userManager.GeneratePasswordResetTokenAsync(user); var result = await _userManager.ResetPasswordAsync(user, token, model.NewPassword); return(result); }
public object ChangePassword([FromBody] ChangePasswordView view) { try { _userService.ChangePassword(GetUserId(), view.Password, view.OldPassword); return(Ok()); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult ChangePassword(ChangePasswordView model) { if (ModelState.IsValid) { _accountService.ChangePassword(model); if (ModelState.IsValid) { ViewBag.Message = "Setting Successfully"; ViewBag.Redirect = Url.Action("/LogOn"); } } return(View(model)); }
private void UserChangePassword() { var cp = new ChangePasswordView(); var cpv = new ChangePasswordViewModel(); cp.DataContext = cpv; cp.ShowDialog(); }
private void ChangePasswordExec() { GalaSoft.MvvmLight.Threading.DispatcherHelper.CheckBeginInvokeOnUI(new System.Action( () => { ChangePasswordView cpv = new ChangePasswordView(); cpv.ShowDialog(); } )); }