Search code examples
parse-platformparse-server

Parse server Having to Logout/Login on each deployment. Session getting destroyed?


Issue Description

Migrated from Parse.com to Parse Server (Sashido hosting). Whenever I deploy my cloud code, I had to logout and login on the client app (iOS) to get results. Without re-logging in, I get empty results. The session token on the client side matches with DB. My request.user prints correctly. Only the queries are not working, no session errors but empty results (array or object). This happens to all queries and it was working fine in Parse.com platform. I have ACLs defined for each row and ACL in request.user is also correct but still no results.

Steps to reproduce

Client iOS code

 let configuration = ParseClientConfiguration {
    $0.applicationId = PARSE_APPLICATION_ID
    $0.clientKey = PARSE_CLIENT_KEY
    $0.server = PARSE_SERVER_URL
    $0.localDatastoreEnabled = true
}
Parse.initializeWithConfiguration(configuration)
PFUser.enableRevocableSessionInBackground()

Server

Parse.Cloud.define("getPastWalks", function(request, response) {
    console.info("user:: " + JSON.stringify(request.user) + JSON.stringify(request.params));
    var fromDate = request.params.fromDate;
    var toDate = request.params.toDate;

    var walk = Parse.Object.extend("Walk");
    var pastWalksQuery = new Parse.Query(walk);
    pastWalksQuery.greaterThanOrEqualTo("dateAndTime", fromDate);
    pastWalksQuery.lessThanOrEqualTo("dateAndTime", toDate);
    pastWalksQuery.descending("dateAndTime");
    pastWalksQuery.include("service");
    pastWalksQuery.limit(request.params.limit);
    pastWalksQuery.find().then(function(walks) {
        console.info("past walk:: " + JSON.stringify(walks));
        response.success(walks);
    }, function(error) {
        response.error(error);
    })
});

Expected Results

The above code should retrieve 'all walks for that particular request.user'.

Actual Outcome

But I am getting empty array. When I logout and login, new session token is generated and it works. Without re-logging, no session token errors, only empty array.

Environment Setup

  • Server

    • parse-server version : 2.2.25-1
    • Localhost or remote server? : Sashido Hosting
  • Database

    • MongoDB version: -
    • Localhost or remote server? : Sashido Hosting

Solution

  • I had to pass sessionToken in the query

    pastWalksQuery.find({sessionToken: request.user.getSessionToken()})
    

    https://github.com/ParsePlatform/parse-server/issues/3456