From 9dd57e1c0b99660def2f0f8002af3f36258d6bd5 Mon Sep 17 00:00:00 2001 From: alison Date: Sun, 12 Feb 2023 11:12:07 -0800 Subject: [PATCH 1/2] Added account linking for development environment --- .env.development | 3 ++- .env.production | 1 + pages/api/auth/[...nextauth].js | 12 ++++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.env.development b/.env.development index 7467c7c9..06b5011b 100644 --- a/.env.development +++ b/.env.development @@ -1 +1,2 @@ -GITHUB_OAUTH_PROVIDER_ENABLED = "true" \ No newline at end of file +GITHUB_OAUTH_PROVIDER_ENABLED = "true" +DANGEROUS_ACCOUNT_LINKING_ENABLED = "true" \ No newline at end of file diff --git a/.env.production b/.env.production index 40177e13..4f09ad49 100644 --- a/.env.production +++ b/.env.production @@ -1 +1,2 @@ GITHUB_OAUTH_PROVIDER_ENABLED = "false" +DANGEROUS_ACCOUNT_LINKING_ENABLED = "false" \ No newline at end of file diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js index 6fabb666..a489c7a3 100644 --- a/pages/api/auth/[...nextauth].js +++ b/pages/api/auth/[...nextauth].js @@ -13,7 +13,11 @@ export const authOptions = { Auth0Provider({ clientId: process.env.AUTH0_CLIENT_ID, clientSecret: process.env.AUTH0_CLIENT_SECRET, - issuer: process.env.AUTH0_ISSUER + issuer: process.env.AUTH0_ISSUER, + // Enable dangerous account linking in dev environment + ...(process.env.DANGEROUS_ACCOUNT_LINKING_ENABLED == 'true' + ? { allowDangerousEmailAccountLinking: true } + : {}) }) // ...add more providers here ], @@ -32,7 +36,11 @@ if (process.env.GITHUB_OAUTH_PROVIDER_ENABLED == 'true') { authOptions.providers.push( GithubProvider({ clientId: process.env.GITHUB_ID, - clientSecret: process.env.GITHUB_SECRET + clientSecret: process.env.GITHUB_SECRET, + // Enable dangerous account linking in dev environment + ...(process.env.DANGEROUS_ACCOUNT_LINKING_ENABLED == 'true' + ? { allowDangerousEmailAccountLinking: true } + : {}) }) ); } From ec585c2d7ce2b5424ebcba70455d210ed443886f Mon Sep 17 00:00:00 2001 From: rubynguyen1510 Date: Sun, 12 Feb 2023 12:54:50 -0800 Subject: [PATCH 2/2] i Changes to be committed: modified: pages/api/auth/[...nextauth].js --- pages/api/auth/[...nextauth].js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js index a489c7a3..4895ac83 100644 --- a/pages/api/auth/[...nextauth].js +++ b/pages/api/auth/[...nextauth].js @@ -46,3 +46,9 @@ if (process.env.GITHUB_OAUTH_PROVIDER_ENABLED == 'true') { } export default NextAuth(authOptions); + +/* Test Cases + Auth0 Google/GitHub -> GitHub + GitHub -> Auth0 Google/GitHub + + Tested on Incognito tab of Microsoft Edge, Brave, Safari, Chrome, FireFox*/