Change user password on the front end I'm building a profile page for members on a site where members can change their password. I'm sending the request with ajax, and can successfully change password if I have the input name "password" correct with the users current password.

My problem is that I get a success-response, when I should have gotten an error-response. (Password isn't changed, but I have no way of telling the user there was en error).

My JS is something like this:

$.ajax({
    type: "POST",
    url: "",
    data: dataString,
    success: function(data) {
        console.log("Password successfully changed");
    },
    error: function(data) {
        console.log("Error. Password did not change");
    }
});
Currently the users/saveUser (and the deprecated users/setPassword) controller action doesn’t support Ajax requests, so there won’t really be an easy way to tell if it worked or not.

If you really want to update user passwords over Ajax, your best bet will be to write a plugin with its own custom controller action, which mimics the password-related stuff in UsersController::actionSaveUser(), but probably calls UsersService::changePassword() rather than saveUser() since you only care about updating the password. And have that controller respond with JSON if it’s an Ajax request, rather than assuming it’s not.

Take a look at EntriesController::actionSaveEntry() for an example of a controller action that does support Ajax.