File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -241,18 +241,15 @@ const nextAuthResult = NextAuth({
241241 callbacks : {
242242 async signIn ( { account } ) {
243243 const matchingProvider = account
244- ? getProviders ( ) . find ( ( p ) => {
245- const providerId = typeof p . provider === 'function'
246- ? p . provider ( ) . id
247- : p . provider . id ;
248- return providerId === account . provider ;
249- } )
250- : undefined ;
251-
252- const isAccountLinkingAttempt =
253- ( account ?. type === 'oauth' || account ?. type === 'oidc' ) &&
254- matchingProvider ?. purpose === 'account_linking' ;
255-
244+ ? getProviders ( ) . find ( ( p ) => {
245+ const providerId = typeof p . provider === 'function'
246+ ? p . provider ( ) . id
247+ : p . provider . id ;
248+ return providerId === account . provider ;
249+ } )
250+ : undefined ;
251+
252+
256253 // Refuse OAuth signin for providers configured purely for account
257254 // linking when no authenticated user is present on the request.
258255 //
@@ -272,6 +269,7 @@ const nextAuthResult = NextAuth({
272269 // `AccessDenied` before handleLoginOrRegister can run, redirecting
273270 // the user to the error page instead of leaving them stranded as a
274271 // new orphan identity with no UserToOrg row.
272+ const isAccountLinkingAttempt = matchingProvider ?. purpose === 'account_linking' ;
275273 const session = await auth ( ) ;
276274 if ( isAccountLinkingAttempt && session === null ) {
277275 return false ;
You can’t perform that action at this time.
0 commit comments