As a headless developer I can access the current user's name, username, etc. easily #4810
Labels
contributions welcome
Contributions from the community would be especially welcome on this ticket.
enhancement
good first issue
Originally:
apostrophecms-legacy/apostrophe-headless#61
(Back in the A2 era, but still a good idea)
Right now a pure headless Apostrophe developer can't display the current user's name, which is silly and lacks parity with what Nunjucks developers can easily do.
Of course they can implement their own apiRoute for it at project level but it is good for headless developers to have access to things with roughly the same level of effort as those using ordinary full page Apostrophe rendering.
The goal is to implement the following API via the
apiRoutes
feature in Apostrophe's core login module:Which would return the following information about the user who made the request (
req.user
):The @apostrophecms/login module would be given new options, minimumWhoamiFields and whoamiFields. minimumWhoamiFields would default to [ '_id', 'username', 'title', 'email' ] and whoamiFields would default to []. The final list would be the concatenation of the two.
This is for convenience: developers can add fields without restating the list or accidentally breaking code that reasonably relies on this API's defaults unless they really want to go there.
If
req.user
does not exist a 404 should be generated (throw self.apos.error('notfound')
)Since we don't have a customer requirement for this at this time, I've tagged it for a potential open source community contribution. Due to the clear technical description above, I have also tagged it as a good first issue for anyone willing to spend time with the Apostrophe documentation re:
apiRoutes
.[Internal note: see PRO-6828]
The text was updated successfully, but these errors were encountered: