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
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3113585-after-8.png | 42.51 KB | shyam_bhatt |
| #7 | drupal-http-user-login-include-uuid-3113585-7.patch | 1.6 KB | pingwin4eg |
Issue fork drupal-3113585
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
Comment #2
ghost of drupal pastBTW the user register REST endpoint should be moved into user but that's a different issue.
Comment #3
ghost of drupal pastComment #4
ghost of drupal pastPer 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.
Comment #5
devakintunde commentedKindly 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.
Comment #6
pingwin4eg@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.idproperty. For anonymous usersmetaproperty 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.
Comment #7
pingwin4egRerolled the patch for current stable core 9.4.5
Comment #8
shyam_bhattI 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.
Comment #10
shyam_bhattComment #11
catchI 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.
Comment #15
theduke13 commentedI'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!