gpt4 book ai didi

javascript - 在 Cloud Code 中检索用户密码

转载 作者:搜寻专家 更新时间:2023-10-31 23:03:59 25 4
gpt4 key购买 nike

是否可以使用 myUser.get("password") 在 Cloud Code 中检索用户密码?我什至在使用主 key ,但我仍然无法取回它。


更新:

 PFCloud.callFunctionInBackground("updateUser", withParameters: ["username" : username, "newPassword" : newPasswordText.text, "currentPassword" : currentPasswordText.text, "operation" : 2]) {
(positions: AnyObject!, error: NSError!) -> Void in
if error == nil {

self.navigationController?.popToRootViewControllerAnimated(true)
}

else {

let errorAlert = UIAlertController (title: "Error", message: "Invalid current password", preferredStyle: UIAlertControllerStyle.Alert)

let actionCancel = UIAlertAction (title: "Dismiss", style: .Cancel, handler: nil)

errorAlert.addAction(actionCancel)

self.presentViewController(errorAlert, animated: true, completion: nil)

}
}

Parse.Cloud.define("updateUser", function(request, response) {
// Set up to modify user data
Parse.Cloud.useMasterKey();
var query = new Parse.Query(Parse.User);
query.equalTo("username", request.params.username);
query.first({

success: function(myUser) {

var password = myUser.get("password");

if (request.params.operation == 1) {

myUser.set("password", request.params.newPassword);

}

else if (request.params.operation == 2 && password == request.params.currentPassword) {

myUser.set("password", request.params.newPassword);

}

else {

response.error(password);
}

myUser.save(null, {

success: function(myUser) {
// The user was saved successfully.
response.success("Successfully updated user.");
},

error: function(myUser, error) {
// The save failed.
// error is a Parse.Error with an error code and description.
response.error("Could not save changes to user.");
}
});

},

error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
});

最佳答案

密码在 Parse 中存储为单向哈希值,无论设置什么权限都无法检索。它只能与另一个潜在密码的哈希值进行比较,但您仍然永远无法找回原始密码。

如果用户输入了他们的电子邮件地址,您可以请求密码重置过程。

Parse.User.requestPasswordReset("email@example.com", {
success: function() {
// Password reset request was sent successfully
},
error: function(error) {
// Show the error message somewhere
alert("Error: " + error.code + " " + error.message);
}
});

关于javascript - 在 Cloud Code 中检索用户密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28840841/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com