-
Notifications
You must be signed in to change notification settings - Fork 585
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
JWT metadata missing on User object #3268
Comments
The HTTP request to https://eu-west-1.aws.stitch.mongodb.com/api/client/v2.0/auth/profile does return the missing data fields, so I think this is a problem in the code which parses that response. |
Shouldn't that go into |
I don’t think so, that is a different feature. |
I can see on the screenshot that you're using a slash in the key path when setting up metadata fields. Are you sure those shouldn't be dots? See dot notation. That being said, there might very well be an issue here we need to investigate. Can you confirm the data is not present on the |
I've done some investigating by comparing the Both SDK's fetch the user profile and both receive the same response from the server, including the The Stitch SDK uses the following field mapping to copy the data into the profile:
See here: The Realm Web SDK uses a different mapping. This mapping does not contain the
See here: realm-js/packages/realm-web/src/User.ts Line 245 in 99e5df1
|
Thanks a lot for the initial investigation, I agree we have a discrepancy here which we need to get fixed. |
Would it help and/or speed things up if I submit a PR which fixes this? I’m guessing I should use the v10 branch as starting point? |
That would be awesome. |
@kraenhansen - should this work now? I have version 10.2.0 of realm using a custom JWT authentication provider and custom profile data is not working as expected. As a work around we are currently using the birthday field on profile to pass a value down that we need. See screen shot then after login If I inspect the profile like so
then the opu field is not present.
Thanks Andy |
@andrew-whitmore short answer is no. |
@kraenhansen posting this here because it has a recent reply. I you prefer me to create a new issue let me know. I have upgraded one of our web apps from the old stitch SDK to the new realm web SDK. Everything works properly and I am receiving the Auth0 data now. Thanks again for fixing this 🙏 There's only one small issue with TypeScript. All the additional properties on Line 614 in 3632b78
This is a problem, because these properties can also be any other type, for example the Which means I have to convert the property to unknown (to get rid of the string type) before I can use them, for example: const roles = (user.profile.roles as unknown) as Record<string, boolean>
const app_metadata = (user.profile.app_metadata as unknown) as MyAppMetadata Would it be possible to change the type of the additional properties to |
@rvanmil I'm happy that it's working and I agree I want to make sure I also mention that we've made the |
Thanks!
That would be even better than having unknown types 😊 If you could share an example that would be great. |
Goals
I have specified metadata fields in the custom JWT authentication settings, but these fields do not appear on the user object after logging in.
I am working with
realm-web
version0.9.0
Expected Results
When using the Stitch SDK these fields could be found on the
user.profile.data
object (mongodb-stitch-browser-sdk
version4.8.0
).Actual Results
The
user.profile.data
object does not exist. See screenshots.Steps to Reproduce
Use custom JWT authentication with metadata fields. Login in the browser and check the logged in user object.
Code Sample
Version of Realm and Tooling
The text was updated successfully, but these errors were encountered: