Migrating to self hosted Parse Server isn't giving me the logged user

I'm trying to migrate my Parse server to my own server instance in DigitalOcean. After deploying my parse-server I'm falling in some issue I can't understand.

When you make a call to the Cloud Code, you can retrieve your user as request.user if you have revocable sessions enabled.

Everything is OK, but sometimes (random times) I get this strange behaviour: my request.user doesn't appear in Cloud Code.

I thought it could be a bad session token so I got rid of it by doing:

if (!request.user) { 
    response.error("INVALID_SESSION_TOKEN"); 
    return; 
}

and obbligate the user to log-in again.

This wasn't working, I was getting an INVALID_SESSION_TOKEN everytime I log in, so I decided to debug. These are my steps:

1.- Log in my user, so a _Session object is created:

so the sessionToken is r:a425239d4184cd98b9b693bbdedfbc9c

2.- Make call cloud function (sniff log):

POST /parse-debug/functions/getHomeAudios HTTP/1.1

X-Parse-OS-Version: 6.0.1

X-Parse-App-Build-Version: 17

X-Parse-Client-Key: **** (hidden)

X-Parse-Client-Version: a1.13.0

X-Parse-App-Display-Version: 1.15.17

X-Parse-Installation-Id: d7ea4fa0-b4dc-4eff-9b7d-ff53a1424dcb

User-Agent: Parse Android SDK 1.13.0 (com.pronuntiapp.debug.uat/17) API Level 23

X-Parse-Session-Token: r:a425239d4184cd98b9b693bbdedfbc9c

X-Parse-Application-Id: **** (hidden)

Content-Type: applicati¡á“WÇX�

Content-Length: 346

Host: 46.101.89.192:1338

Connection: Keep-Alive

Accept-Encoding: gzip

3.- request.user is still not appearing on CloudCode.


EDIT: Reseting the parse-server worked in this case, but not in some others.

Answers


Days ago I got the solution. When you have successfully deployed your Parse server, you will get request.user from any end point of the cloud, but if you call a cloud function from cloud, you won't get this request.user at least you pass the sessionToken:

Parse.Cloud.define("foo", function(request, response) {
    if (!request.user) {
      response.error("INVALID_SESSION_TOKEN");
      return;
    }

    var countResponses = 0;
    var responsesNeeded = 1;

    Parse.Cloud.run('bar', request.params, {
                    sessionToken: request.user.getSessionToken(),
                    success: function(c) {
                      countResponses++;
                      result = c;
                      if (countResponses >= responsesNeeded) {
                        response.success(result);
                      }
                    },
                    error: function(error) {
                      response.error(error);
                    }
                  });
});

in this case, foo will have request.user and bar won't, unless you pass sessionToken.


Need Your Help

Insert a liferay portlet into PrimeFaces dialog

jsf-2 primefaces liferay liferay-6

I'm using liferay 6.1, jsf 2 and primeface 4.0. I've two different project running on a liferay tomcat. I want to insert a portlet of "Project 1" into primefaces dialog of "project 2".

SFML Errors in VS 2010

c++ visual-studio-2010 visual-c++ sfml

I tried this simple test to see if it would work: