Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

As a headless developer I can access the current user's name, username, etc. easily #4810

Open
boutell opened this issue Nov 20, 2024 · 3 comments
Labels
contributions welcome Contributions from the community would be especially welcome on this ticket. enhancement good first issue

Comments

@boutell
Copy link
Member

boutell commented Nov 20, 2024

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:

GET /api/v1/@apostrophecms/login/whoami

Which would return the following information about the user who made the request (req.user):

{
  _id,
  username,
  title,
  email
}

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]

@boutell boutell added enhancement good first issue contributions welcome Contributions from the community would be especially welcome on this ticket. labels Nov 20, 2024
@KDrop25
Copy link

KDrop25 commented Nov 25, 2024

hi can i work on this issue is it still open to work on ?

@adarsh1114
Copy link

hi @boutell , can you please assign this task to me?

@BoDonkey
Copy link
Contributor

BoDonkey commented Dec 7, 2024

Hi @KDrop25 and @adarsh1114,
We don't "assign" issues. If you want to work on this issue, go at it! Right now the issue is still open. If you two want to collaborate on this you can, or go ahead and try to create a solution on your own. I'm mostly available here and in our Discord (https://discord.com/invite/HwntQpADJr) channel if you have questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions welcome Contributions from the community would be especially welcome on this ticket. enhancement good first issue
Projects
None yet
Development

No branches or pull requests

4 participants