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

fix: incorrect assignment of displayName for Apple OAuth #425

Merged
merged 8 commits into from
Nov 6, 2023

Conversation

@changeset-bot
Copy link

changeset-bot bot commented Oct 26, 2023

🦋 Changeset detected

Latest commit: 7a63363

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
hasura-auth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@totzk9
Copy link
Contributor Author

totzk9 commented Oct 26, 2023

Hi, I haven't tested this yet and I don't know how to setup hasura-auth to my local.

but based from docs, I believe this should be the correct response

@dbarrosop
Copy link
Member

Thanks a lot for the PR.

To test locally you can run:

docker build -t nhost/hasura-auth:local .

Then, if you have an nhost project using the cli you can temporarily set the auth version to local to use this image.

When you manage to test it and verify it works send us a few screenshots capturing the result (or even a loom video) and we will merge. If you need help with the test don't hesitate to ping me on discord.

@totzk9
Copy link
Contributor Author

totzk9 commented Oct 26, 2023

@dbarrosop Will do. thanks!

@totzk9
Copy link
Contributor Author

totzk9 commented Oct 27, 2023

Here are my local tests with the following videos.

  1. Testing the current v0.21.2. The current implementation doesn't properly fetch the user's info from Apple
cb54599f-5839-4d11-89c9-2e4f3a21dbc8.mp4
  1. I've added logs to see and compare the json data taken from jwt and profile params.
c8ea1b69-6cb7-4144-bd5f-63ab2964d4f8.mp4
  1. I've encoded profile into a JSON object because it's a stringified json then used the user variable to assign it to the displayName field.
0042d6df-40ab-4514-884b-d67b75921718.mp4

Please do final tests. I'm not too familiar with the whole project, I might break some stuff.

Thank you

@totzk9
Copy link
Contributor Author

totzk9 commented Oct 27, 2023

The 7cc7422 commit fixes an issue where if an existing Apple user reauthenticates, it breaks.

Here are the following behaviours:

  1. If new user signs up, then the profile param is a stringified Object thus we need to parse it using JSON.parse(profile)
  2. If user is already exists and reauthenticates, then the profile param is not a stringified Object causing the JSON.parse(profile) to throw an exception.

Solution: I wrapped it in a try catch. Let me know if you want to have requested changes for this one.

Test Video:

bd55d775-c1a1-4892-b512-1d718b848263.mp4

@totzk9 totzk9 changed the title fix: incorrect assignment of displayName fix: incorrect assignment of displayName for Apple OAuth Oct 27, 2023
@onehassan
Copy link
Member

@totzk9 Thank you for the PR 🙌 - Will look into this now

@onehassan
Copy link
Member

Thank you again @totzk9 for the PR 👍 . I've made some adjustments and added a changeset.
We will merge very soon!

src/routes/oauth/config.ts Outdated Show resolved Hide resolved
: displayName;
} catch (error) {
logger.warn(
`Problem trying to parse user data from apple's response: ${error}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicking but I'd add , default to email

@onehassan onehassan merged commit 2aa0d6d into nhost:main Nov 6, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants