I have one additional API route which starts an import proces. The route is configures in the global Payload config:
express: {
postMiddleware: [importAccess],
},
endpoints: [
{
path: "/import/run/:collection",
method: "get",
handler: importHandler,
},
],
Most works as expected, but i can't seem to get access control working within the middleware or route itself. What i would like to do is call a generic "isAdmin" function (which i already use in other places) on an user object. But the user variable within the request is always undefined. A workaround was loading the import global collection which as access control on it. According to the documentation, access control should be invoked when using req.payload.findGlobal but this is not the case. The collection object is always returned when calling the custom API route. Calling the normal API route for this collections results in a 403 error as expected.
What is the correct way to handle this? Thanks.