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
When saving a new PFUser on iOS, the SDK(?) throws this error:
Caught "NSInternalInconsistencyException" with reason "User cannot be saved unless they are already signed up. Call signUp first."
When saving a new PFUser via Cloud Code, it does not throw that error but simply mimics a "signUp", which creates a session token for the server... in Cloud Code! (actually, read #3 as this may be a bug with the pfuser handling)
For sake of flexibility and consistency (with PFObjects), I think there should be an option to "save" a PFUser without having a session token created, or restricting (iOS) apps to always use PFUser.signUp. There are many use-cases for such a feature, and I feel that it is a meaningless restriction.
Personal use-case: I have some special logic to replace the standard "signUp" flow, which has me creating a PFUser via Cloud Code + MasterKey. But with how the "save" function is behaving, it's creating a session token for the server!
let user = new Parse.User()
user.save();
// and
let user = new Parse.Object('_Users')
user.save();
// and
let user = new Parse.User()
user.signUp("username","password")
all 3 make calls to the /users endpoints, so we can't really infer anything from that.
Another option would be to skip the session creation when using { useMasterKey: true }.
That seems reasonable as I can't think of a good reason to want to create a sessionToken as master.
Another option would be to skip the session creation when using { useMasterKey: true }.
That seems reasonable as I can't think of a good reason to want to create a sessionToken as master.
That sounds good. Would it apply to all SDKs that are connected with the masterkey as well?
@drew-gross is that reasonable? Or maybe we can check the request headers and make sure we don't generate a Session Token for Cloud Code, nor nodejs, nor REST etc... I tend to think the masterKey is a workaround.
Checking IS_NODE seems like a good solution. Sometime you want to make requests as a specific user even in Cloud Code so having that work as expected and not create session tokens is important.
@drew-gross once again, we face an issue with parse.js being single minded. I overrode the InstallationsController to return 'parse-server' as the installationId (as it is in regular parse.com's cloud code). The problem being that it breaks all of our tests.
we could overcome that maybe by running the cloud endpoint in their own VM...
Is there a work around for this I can write myself? I am running an app that uses a slightly modified version of AnyPhone and all my users are created and log in through Cloud Code.
This is the final barrier between my full migration off of parse.com.
@flovilmart we have Google login implementation with Cloud code in Android. but now with the revocable sessions we are not able get the session token from cloud code when user trying to login/signup. then we have added bellow code:
var session;
var query = new Parse.Query("_Session");
query.equalTo('user', user);
query.first({ useMasterKey: true }).then(function(tokenData) {
res.success(tokenData.get("sessionToken"));
});
This will return Session token from _Session class but when user logged out and trying to login again the is no data in Session class as session get deleted after user logged out.
Now i am trying http://stackoverflow.com/a/36656209/3758024 this approach and getting error "can not modify user XXXXX".
Is there anything which i am missing? or Do you have any suggestions? We're on a really tight deadline and we can't seem to find a solution anywhere. Thanks!"
@flovilmart I tried PARSE_SERVER_ENABLE_EXPERIMENTAL_DIRECT_ACCESS=1 on my local server (parse-server@2.3.0), there is no session created when create a new user in the cloud function:
And then I tried to do cloud Parse.User.logIn later to generate associated session, it's created successfully, but installationId field missing, the data passed to RestWrite is
If I get rid of PARSE_SERVER_ENABLE_EXPERIMENTAL_DIRECT_ACCESS=1, there is installationId passed in to create new session.
I called the same cloud function with same parameters, just changed the env setting to start parse server. Not sure if need to enable this, but duplicate session would exist without it
Activity
DoneStuffGetting commentedon Apr 15, 2016
Session token bug --> #1497
flovilmart commentedon Apr 20, 2016
Just investigate that one and:
all 3 make calls to the /users endpoints, so we can't really infer anything from that.
Another option would be to skip the session creation when using
{ useMasterKey: true }.That seems reasonable as I can't think of a good reason to want to create a sessionToken as master.
DoneStuffGetting commentedon Apr 20, 2016
That sounds good. Would it apply to all SDKs that are connected with the masterkey as well?
flovilmart commentedon Apr 20, 2016
Yeah REST, node etc...
flovilmart commentedon Apr 20, 2016
@drew-gross is that reasonable? Or maybe we can check the request headers and make sure we don't generate a Session Token for Cloud Code, nor nodejs, nor REST etc... I tend to think the masterKey is a workaround.
We could use the User-Agent: https://github.com/ParsePlatform/Parse-SDK-JS/blob/master/src/RESTController.js#L129
drew-gross commentedon Apr 20, 2016
Checking IS_NODE seems like a good solution. Sometime you want to make requests as a specific user even in Cloud Code so having that work as expected and not create session tokens is important.
flovilmart commentedon Apr 20, 2016
ok so I'll check for the User-Agent somewhere
flovilmart commentedon Apr 24, 2016
@drew-gross once again, we face an issue with parse.js being single minded. I overrode the InstallationsController to return 'parse-server' as the installationId (as it is in regular parse.com's cloud code). The problem being that it breaks all of our tests.
we could overcome that maybe by running the cloud endpoint in their own VM...
drew-gross commentedon Apr 25, 2016
Which tests does it break and why? If
parse-serveris what Parse.com returns, we should try to do the same thing.pbmarcano commentedon May 4, 2016
Is there a work around for this I can write myself? I am running an app that uses a slightly modified version of AnyPhone and all my users are created and log in through Cloud Code.
This is the final barrier between my full migration off of parse.com.
Do not create sessionToken when requests come from cloudCode #1495
Do not create sessionToken when requests come from cloudCode #1495
Direct Access to parse-server (#2316)
abhijeet-aressindia commentedon Nov 8, 2016
@flovilmart we have Google login implementation with Cloud code in Android. but now with the revocable sessions we are not able get the session token from cloud code when user trying to login/signup. then we have added bellow code:
var session;
var query = new Parse.Query("_Session");
query.equalTo('user', user);
query.first({ useMasterKey: true }).then(function(tokenData) {
res.success(tokenData.get("sessionToken"));
});
This will return Session token from _Session class but when user logged out and trying to login again the is no data in Session class as session get deleted after user logged out.
Now i am trying http://stackoverflow.com/a/36656209/3758024 this approach and getting error "can not modify user XXXXX".
Is there anything which i am missing? or Do you have any suggestions? We're on a really tight deadline and we can't seem to find a solution anywhere. Thanks!"
pbmarcano commentedon Jan 26, 2017
@gopal-aressindia did you find a solution for this? I am trying to get back to this issue for a project migration before the upcoming deadline
abhijeet-aressindia commentedon Jan 27, 2017
@pbmarcano No, I don't find any solution on this. I have changed this process and now removed cloud code and using the Third Party OAuth
6thfdwp commentedon Mar 25, 2017
@pbmarcano seems AnyPhone link cannot be reached any more, can you still access it?
I just built some prototype for phone based login on self-hosted parse server, would be helpful to see original code repo to get the whole flow right
6thfdwp commentedon Mar 25, 2017
@flovilmart I tried
PARSE_SERVER_ENABLE_EXPERIMENTAL_DIRECT_ACCESS=1on my local server (parse-server@2.3.0), there is no session created when create a new user in the cloud function:And then I tried to do cloud
Parse.User.logInlater to generate associated session, it's created successfully, butinstallationIdfield missing, the data passed toRestWriteisIf I get rid of
PARSE_SERVER_ENABLE_EXPERIMENTAL_DIRECT_ACCESS=1, there is installationId passed in to create new session.I called the same cloud function with same parameters, just changed the env setting to start parse server. Not sure if need to enable this, but duplicate session would exist without it
flovilmart commentedon Mar 25, 2017
yoi should probably not call login from cloud code. Sessions are tied to the installationId.
Also, i believe you can pass the installationId that was passed to the cloud function call to the logIn options object https://github.com/ParsePlatform/Parse-SDK-JS/blob/master/src/ParseUser.js#L429
This will effectively create a session for the installationId that you gave.
But like I said, you should not call logIn in Cloud Code as it doesn't really make sense.
6thfdwp commentedon Mar 25, 2017
Great, thanks for the explanation. I'll probably rethink the login flow again.
montymxb commentedon Sep 10, 2017
@flovilmart with a PR submitted (and merged) is there anything else that needs to be squared away for the original issue here?
flovilmart commentedon Sep 10, 2017
Nope! Everything is good, we need to setup direct access mainline at one point .