Parse CloudCode SetPassword Always Fails

六月ゝ 毕业季﹏ 提交于 2019-12-11 17:47:51

问题


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.

来源:https://stackoverflow.com/questions/33370839/parse-cloudcode-setpassword-always-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!