Access pointer data from request.user

When performing a cloud code request via REST you can access the user in the function by request.user.

I have some pointers on my user to other classes. I would like to extend the request.user to always include this pointer data? Is this possible?

async getUploadSignature(request) {
  console.log(request.user);
}
ParseUser {_objCount: 493, className: "_User", id: "ZZkdk234Wh"}
className: "_User"
id: "ZZk23448Wh"
_objCount: 493
attributes: {
  ACL: {}
  email: "[email protected]",
  permissions: ParseObject
  className: "Permissions"
  id: "Whv1231CFR"
  _objCount: 496,
  attributes: <----------------------- Unable to access this object & it's data
...

Is it possible to include this pointer on all request.user objects as we would query for it in a normal extended query :

const data = await new Parse.Query('_User')
  .equalTo('objectId', userId)
  .include('permissions')
  .first({ useMasterKey: true });

(all ObjectIDs are fake in case you were wondering :man_shrugging:t3:)

I’ve never tried it before but you can try with a beforeFind trigger. I’d try something like this:

Parse.Cloud.beforeFind('_User', (req) => {
  req.query.include('attributes');
});

Hey @davimacedo,

Tried this, it doesn’t work unfortunately. Do you know how Parse gets the user object from a request which holds only the sessionToken. Surely it is performing some sort of user query on the _User class?

It is this function which is called by this middleware every request.

It actually bypasses the trigger, since it uses RestQuery directly and triggers are handled one layer above at: https://github.com/parse-community/parse-server/blob/master/src/rest.js#L61

So I think there isn’t currently a solution for what you need.