-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
Configure NextAuth to allow account linking between different providers in development environment #248
Conversation
Hi team, thanks for taking on this issue and working with us as the issue evolved! I was wondering, for the Is allowing account linking based purely on if the account's main provider (i.e. the one you signed in first with) allows it, or is it if the current provider you are trying to use allows it? ex: Initial account is made with GitHub Auth and does not have Was this something that the team investigated? |
Hi Guillermo (@GuillermoFloresV), The Account linking is based on if the current provider allows it or not. With the example you gave us (Enable Auth0 linking and Disable GitHub linking), if you sign in with GitHub first (initial account) and then sign in with Auth0 second, it will successfully link since Auth0 Linking is enabled.
However, if we flipped the sign-in options, by logging in with Auth0 first (initial account) and then GitHub, we would receive the original error: "To confirm your identity, sign in with the same account you used originally," meaning that the accounts would be unsuccessful in linking due to GitHub linking being disabled.
We also tried your example the other way around (Disable Auth0 linking and Enable GitHub linking) and signed in with Auth0 first (initial account) and then signed in with GitHub second, and the accounts were successfully linked as well due to GitHub linking being enabled.
Once again flipping the sign-in options, signing in with GitHub first (initial account) and then Auth0 would produce the original error, meaning that the accounts would be unsuccessful in linking due to Auth0 linking being disabled.
I hope this answers your questions, if not, please feel free to let us know. |
That answers my question, thanks @rahulio96! Great job to the team for investigating so much into this issue! |
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
Auth0Provider
object and theGithubProvider
object. 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 develop
To test, follow the same process, but you should not receive an error.
To unlink your accounts after each test case:
npx prisma studio
Test 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 Account
indicates that Auth0 Google, Auth0 Github, and Github have been linked together.