Configure NextAuth to allow account linking between different providers in development environment #248
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist:
Update index.md)Closes #219
Authors: Alison Fung, Rahul Gupta, Ngoc Nguyen
Summary
Currently, logging in to Classroom through Auth0 with Google and then attempting to log in through Auth0 with Github using an account that has the same email associated with it returns the following error:
This solution adds account linking support for the development environment so that you are able to log in successfully without this error.
Details
This solution uses the spread operator to add an object property to the
Auth0Providerobject and theGithubProviderobject. It also adds a new environment variable to only enable account linking in the development environment.Testing
We tested on a local build with three options to login: Auth0 Google, Auth0 Github, and Github.
Note: When logging into Auth0 a second time, we had to use an Incognito/Private tab. Otherwise, it automatically logs you in without letting you choose between Google or Github.
To reproduce the problem:
npm run developTo test, follow the same process, but you should not receive an error.
To unlink your accounts after each test case:
npx prisma studioTest Cases (Normal window -> Incognito window):
Logging into the third option after any two also links all three together. You can check this within Prisma Studio, such as in the image below:
The
3 Accountindicates that Auth0 Google, Auth0 Github, and Github have been linked together.