You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have parse server set up in my own domain. I am trying the custom password reset functionality like below using rest api. Every other field update works other than the password field. Could you guide me how i can resolve this. I am using the master key.
app.get("/updatepassword", function(req, res) {
var options = {
host : '<mydomian>',
port : '<portno>',
method: 'PUT',
path : '/parse/classes/_User/' + req.query.userId,
headers : { 'X-Parse-Application-Id' : 'testappid' , 'X-Parse-Master-Key' : 'testmasterkey', 'Content-Type' : 'application/json' }
}
var data = JSON.stringify({
password: req.query.password
});
var req = http.request(options, function(response) {
// Continuously update stream with data
var body = '';
response.on('data', function(d) {
body += d;
});
response.on('end', function() {
});
});
req.write(data);
req.end();
Javascript sdk have same problem, so does cloud function.
Here is Javascript code, run on node.js 4.2.4
var Parse = require('parse/node').Parse;
Parse.initialize("myAppId", "myJavascriptKey","masterKey");
Parse.serverURL = 'http://xxxx:1337/parse'
var query = new Parse.Query(Parse.User);
query.equalTo("email", "myEmail");
query.first().then(function(user){
console.log(user.get('name'));
user.setPassword("12345689");
user.save(null,{useMasterKey:true}).then(console.log,console.log);
},console.log);
I get { code: 101, message: 'Object not found.' }
I can query this user, but cannot setPassword with masterKey.
Changing other field is work as expected.
This code is work on the original API server (host on Parse).
That PR doesn't use user.setPassword with master key so I don't think it's the issue seen by @srinivasagopalan and @sdf611097. Could you two look at that PR and see if it's close to what you are trying to do?
@flovilmart PR 476 will avoid it failed. @drew-gross
We are trying to do is changing password, and it is different to modify other field.
Password is special, and I found that failed by clear no _Session.
I have PR 476 and it have been merged.
All I want to do is setting random password for user, and user use it to login.
Before setting password, the _Session may not exist.
BTW.
The original purpose is use masterKey to get session token, and then pass to client.
Client use that token with ParseUser.become to login.
It is failed. I think it is due to API server required revocable session, but myApp does not use that.
So I try to use a random password with it account instead legacy token functionality.
(MyApp use my custom 3rd login, password is saved on other place. My cloud function just verify it and let user login with ParseUser)
This does sound like an issue caused by not having revocable sessions in your original parse app. Parse Server currently doesn't support old-style sessions. We would welcome any PRs that help work around that problem, though.
Activity
sdf611097 commentedon Feb 17, 2016
Javascript sdk have same problem, so does cloud function.
Here is Javascript code, run on node.js 4.2.4
var Parse = require('parse/node').Parse;
Parse.initialize("myAppId", "myJavascriptKey","masterKey");
Parse.serverURL = 'http://xxxx:1337/parse'
var query = new Parse.Query(Parse.User);
query.equalTo("email", "myEmail");
query.first().then(function(user){
console.log(user.get('name'));
user.setPassword("12345689");
user.save(null,{useMasterKey:true}).then(console.log,console.log);
},console.log);
I get { code: 101, message: 'Object not found.' }
I can query this user, but cannot setPassword with masterKey.
Changing other field is work as expected.
This code is work on the original API server (host on Parse).
My api server log with VERBOSE=1
PUT /parse/classes/User/userId { 'user-agent': 'node-XMLHttpRequest, Parse/js1.7.0 (NodeJS 4.2.4)',
accept: '/_',
'content-type': 'text/plain',
host: 'myhostxxx:1337',
'content-length': '175',
connection: 'close' } {
"password": "12345689"
}
error: ParseError { code: 101, message: 'Object not found.' }
srinivasagopalan commentedon Feb 17, 2016
I get the same error as well
sdf611097 commentedon Feb 18, 2016
Once change password, it will clear all sessions. If no session found, will get object not found.
If login first, and then change password seems work.
Can I use legacy token and without any _Session?
flovilmart commentedon Feb 19, 2016
@drew-gross trouble shooter, see the related PR, seems that the use case is actually not failing.
drew-gross commentedon Feb 19, 2016
That PR doesn't use
user.setPasswordwith master key so I don't think it's the issue seen by @srinivasagopalan and @sdf611097. Could you two look at that PR and see if it's close to what you are trying to do?flovilmart commentedon Feb 19, 2016
set("password", pass)is different fromsetPassword(pass)in the client SDK?flovilmart commentedon Feb 19, 2016
@drew-gross updated with
setPassword(password)to matchstill not failing...
sdf611097 commentedon Feb 19, 2016
@flovilmart PR 476 will avoid it failed.
@drew-gross
We are trying to do is changing password, and it is different to modify other field.
Password is special, and I found that failed by clear no _Session.
I have PR 476 and it have been merged.
All I want to do is setting random password for user, and user use it to login.
Before setting password, the _Session may not exist.
BTW.
The original purpose is use masterKey to get session token, and then pass to client.
Client use that token with ParseUser.become to login.
It is failed. I think it is due to API server required revocable session, but myApp does not use that.
So I try to use a random password with it account instead legacy token functionality.
(MyApp use my custom 3rd login, password is saved on other place. My cloud function just verify it and let user login with ParseUser)
flovilmart commentedon Feb 19, 2016
OK I'm closing the PR as the troubleshoot really don't get us anywhere near the problem.
drew-gross commentedon Feb 19, 2016
This does sound like an issue caused by not having revocable sessions in your original parse app. Parse Server currently doesn't support old-style sessions. We would welcome any PRs that help work around that problem, though.