2

I am migrating Parse.com cloud code to hosted parse-server. Mongodb is already migrated.

The code is supposed to retrieve a user's sessionToken according to its google plus id. The find operation succeeds and a user is returned but the user does not have any sessionToken.

EDIT regarding mongodb: Checking mongo db directly - the _User table record holds a _session_token value. In the _Session table I could not find that _session_token. Also I could not find any entry for that _User (I concatenated _User$ when searching).

The code is (more or less) so:

Parse.Cloud.define("getParseUserSessionToken", function(request, response) {
        var googlePlusId = ...;
        // here we're doing some code to get the google id
        // assume it is set

        var googleIdQuery = new Parse.Query(Parse.User);
        googleIdQuery.equalTo(GOOGLE_PLUS_ID_FIELD_KEY, googlePlusId);

        searchUserQuery.find({
            useMasterKey: true
        }).
        then(function(users) {
                    if (users && users.length > 0) {

                        var user = users[0]; //user exist

                        var token = user.getSessionToken();
                        if (token) {
                            //user exist, return sessionToken
                            // ....
                        } else {
                            // CODE REACHES HERE AS THERE'S NO TOKEN
                            // return error: "no token"
                        }
                    }
                }

As you can see I pass userMasterKey: true to find() With a debugger I can see that I get a user with data, but without a token. I tried several things but nothing works.

Any idea what am I missing?

drorsun
  • 881
  • 1
  • 8
  • 22
  • Is there any _Session to point this user? – ChunTingLin May 20 '16 at 12:54
  • Can you please confirm that you use the latest parse-server version ??? Can you see the sessions in MongoDB tables??? – Konstantinos Natsios Jun 15 '16 at 09:40
  • @KwnstantinosNatsios - a fix to my previous comment - I am using parse-server version 2.2.13 , I cannot find a matching record in _Session table of mongodb. So the _User record has a session token but the user does not have a record in _Session and I cannot find the _session_token from the _User in the _Session table – drorsun Jun 16 '16 at 09:51

0 Answers0