0

I want to include functionality to allow users to change their password in Parse within my app. I am using Unity version 5.0.2f1 and building for WebGL. I attempted to use the Parse plugin to handle this, which worked great in the Unity editor, but once I built the app for WebGL, it would no longer work, always returning a BAD REQUEST.

Thus, it looked like the only solution was to attempt to use CloudCode to do it. However, I'm finding that I cannot ever successfully change a password through Cloud Code. My problem is that setPassword() is always returning false. And I can tell it's not working since I can still only log in with the old passwords. I've posted my code below; I think I'm doing it right, but I'm guessing I'm missing something. Any help would be appreciated.

Parse.Cloud.define("testChangePassword", function (request, response) {
    Parse.User.logIn(request.params.username, request.params.password,
    {
        success: function (user) {
            console.log("Change Password - Logged in");
            user.setPassword(request.params.newpassword);
            user.save();
            response.success({ "success": "Success" });
        },
        error: function (user, error) {
            response.error({ "code": error.code, "message": error.message });
        }
    });
});

Things I have tried regarding the CloudCode:

I've run it without first logging in, and that still doesn't work. But I also need to log in so that I can verify that the original password was correct.

I've tried with user.set("password", request.params.newpassword) instead of setPassword(), and that doesn't work.

I've tried without calling user.save() and that doesn't work.

I've tried getting the boolean from setPassword(), and it always returns false.

  • Is the user making the cloud request always the user whose password is to be changed? – danh Oct 27 '15 at 15:04
  • Yeah. The "request" is getting the username and password of the current user from the Parse plugin in Unity. And then it's explicitly updating that user's password. As a note, the CloudCode isn't working in Unity OR when I build for WebGL, which at least lets me know it's consistent. – Tamlyn Miller Oct 27 '15 at 15:08
  • Have you looked at https://parse.com/docs/js/api/classes/Parse.User.html#methods_requestPasswordReset? (also, please note that the logged in user making the request is available in request.user) – danh Oct 27 '15 at 15:20
  • I have looked at the JS API; that helped me figure out how to write the code above. I tried using request.user. First time, I found that it was always returning null. I found that Parse had version 1.6.1 up, so I grabbed that. Now, whenever I attempt to use a CloudCode function with request.user in it, the function doesn't even finish. It just fails to even complete the task and returns a 400 Bad Request error. It's not going to the error code that I wrote in the logIn area. This even happens when I have a line like "var user = request.user;" followed by a response.success. It just fails. – Tamlyn Miller Oct 28 '15 at 14:40

0 Answers0