Why Parse.User.current() returning null?

Hello,

I’m logging my user with ``/parse/login``` endpoint given from parse REST API, which returning my whole logged user object with sessionToken, which is saved to db.

Now when in my custom endpoint /parse/function/customEndpoint i try to retrive Parse.User.current() it’s returning null even when i set requireUser:true. This is example:

Parse.Cloud.define(
  'createTeam',
  async (request) => {
    const user = request.user;
    const userCurrent = Parse.User.current();
    console.log(user.id);
    console.log(user.getSessionToken());
    console.log(userCurrent);
  },
  validator.teamValidation,
  {
    requireUser: true,
  }
);

result of console.log:
image
.
I have no idea why this current() method does not returning my current session user
this is my session:

Parse.User.current() is for the client side only. As the node server can receive many requests per second, storing the current user this way was unsafe so it was deprecated. request.user is the Parse.User who made the request so this should be sufficient.

Also if you are using a custom function validator, you cannot use an object validator. The object validator must be the 3rd argument of Parse.Cloud.define(

1 Like