public override void HandleRequest(string jsonString, AjaxBase ajax)
        {
            User user = User.GetCurrentUser(ajax);
            if (user == null)
            {
                ajax.BadRequest();
                return;
            }

            ChangePasswordRequest request = Utility.ParseJson<ChangePasswordRequest>(jsonString);
            if (request.currentPassword == null || request.currentPassword == "" || request.newPassword == null || request.newPassword.Length < 8 || request.newPassword != request.newPassword2)
            {
                ajax.BadRequest();
                return;
            }

            ChangePasswordResponse response = new ChangePasswordResponse();

            if (!user.MatchPassword(request.currentPassword))
            {
                response.status = 1;
            }
            else
            {
                response.status = 0;
                user.SetPassword(request.newPassword);
                user.Save();
            }

            ajax.ReturnJson(response);
        }
Esempio n. 2
0
        private void SubmitSuccess(ChangePasswordResponse response)
        {
            submittingForm = false;

            switch (response.status)
            {
                case 0:
                    Hide();
                    break;
                case 1:
                    ErrorModal.ShowError(Strings.Get("WrongPassword"));
                    break;
                default:
                    ErrorModal.ShowError(Strings.Get("UnknownError"));
                    break;
            }
        }