Problem/Motivation

To do anything with an entity, you need the UUID of it. For users, if the "View user information" is not granted to users then the request /jsonapi/user/user?filter[uid]= will come back empty and there's just no way to get from the (largely useless) uid to uuid as things stand.

Proposed resolution

Just add the uuid to the login response.

Remaining tasks

Agree, commit.

User interface changes

None.

API changes

It's an addition to a JSON reply.

Data model changes

It's an addition to a JSON reply.

Release notes snippet

Issue fork drupal-3113585

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Charlie ChX Negyesi created an issue. See original summary.

ghost of drupal past’s picture

StatusFileSize
new1.65 KB

BTW the user register REST endpoint should be moved into user but that's a different issue.

ghost of drupal past’s picture

Issue summary: View changes
ghost of drupal past’s picture

Title: http user login needs to include the uuid » http user login needs to include the id/uuid
Status: Needs review » Closed (won't fix)
StatusFileSize
new1.65 KB

Per https://www.drupal.org/node/2984247 this needs to be called ID not UUID. I have added a note to https://www.drupal.org/docs/8/core/modules/jsonapi-module/filtering#comm... as well.

devakintunde’s picture

Kindly allow me to ask why this was marked as "won't fix"?

Would that mean it cannot make it into Drupal core? I want to apply your patch but now I'm sceptical because of this status.

pingwin4eg’s picture

Version: 8.9.x-dev » 10.1.x-dev
Category: Bug report » Feature request
Status: Closed (won't fix) » Needs review

@devakintunde If a user is logged in, you can get their UUID with a request to /jsonapi root page, it's under meta.links.me.meta.id property. For anonymous users meta property is absent.

But I also think it'd be good to have it in the login or login_status response in order to avoid another request.

pingwin4eg’s picture

Title: http user login needs to include the id/uuid » http user login needs to include the uuid
StatusFileSize
new1.6 KB

Rerolled the patch for current stable core 9.4.5

shyam_bhatt’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new42.51 KB

I have checked the "drupal-http-user-login-include-uuid-3113585-7.patch" is working fine.

After applying the patch, we can get the user UUID in the login API response.
Please check the below image.

2022-12-05/3113585-after-8.png

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: drupal-http-user-login-include-uuid-3113585-7.patch, failed testing. View results

shyam_bhatt’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community
catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record

I think this is a good change, and since it's just adding some extra data don't think we need test coverage for it, but it could use a change record to inform people it's available now.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

theduke13 made their first commit to this issue’s fork.

theduke13’s picture

I've re-rolled the changes as an issue fork and updated the usage of $user-> to $account-> as it seems Drupal Core has updated the User controller in this fashion.

Unsure how to formulate a Change Record but if someone can point me in the right direction I'll gladly put together a draft.

Cheers!

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.