private void OnResetPasswordCommand()
 {
     if ((_newPassword == null || _confirmPassword == null) || _newPassword.Equals(_confirmPassword) == false)
     {
         this.AddError("NewPassword", "New Password Does Not Match Confirmation Password");
     }
     else
     {
         this.RemoveError("NewPassword");
         ResetResult result = _userAccountService.ChangeUserPassword(_user, _newPassword);
         Messenger.Default.Send <PasswordChangeSuccessMessage>(new PasswordChangeSuccessMessage(result));
         Messenger.Default.Send <NavigationMessage>(new NavigationMessage("resetresult"));
         NewPassword     = null;
         ConfirmPassword = null;
     }
 }
        public async Task <IActionResult> ChangePassword([FromBody] ChangePasswordDTO data)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await service.ChangeUserPassword(User.Identity.Name, data);

                    return(Ok());
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex.Message));
                }
            }
            return(Conflict(ModelState));
        }
Esempio n. 3
0
        /// <summary>
        /// 修改账户密码/只允许学生修改  教师密码只允许管理员修改
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="UserNewPassword"></param>
        /// <param name="IDNumber"></param>
        /// <returns></returns>
        public String ChangePassword(String UserID, String UserNewPassword, String IDNumber)
        {
            Map.UserType type = UserAccountService.GetUserType(UserID);

            JsonData val = new JsonData();

            if (UserID.Trim() != "" || UserNewPassword.Trim() != "" || IDNumber.Trim() != "")
            {
                FormsAuthentication.SignOut();
                UserAccout accout = new UserAccout();
                accout.UserAccoutID = UserID;
                accout.UserPassword = UserNewPassword;
                Boolean result = UserAccountService.ChangeUserPassword(accout, Map.UserType.Student);
                val["isOk"] = result;//返回状态如何 成功
            }
            else
            {
                RedirectToAction("Error", "Home");
                val["isOk"] = false;//返回状态如何 失败
            }
            return(val.ToJson());
        }