@@ -10,7 +10,7 @@ import { type UseAuthStateReturn, useAuthState } from './useAuthState'
1010import { callWithNuxt } from '#app/nuxt'
1111// @ts -expect-error - #auth not defined
1212import type { SessionData } from '#auth'
13- import { navigateTo , nextTick , useNuxtApp , useRuntimeConfig } from '#imports'
13+ import { navigateTo , nextTick , useNuxtApp , useRoute , useRuntimeConfig } from '#imports'
1414
1515type Credentials = { username ?: string , email ?: string , password ?: string } & Record < string , any >
1616
@@ -60,7 +60,13 @@ const signIn: SignInFunc<Credentials, any> = async (credentials, signInOptions,
6060 const { redirect = true , external } = signInOptions ?? { }
6161 let { callbackUrl } = signInOptions ?? { }
6262 if ( typeof callbackUrl === 'undefined' ) {
63- callbackUrl = await determineCallbackUrl ( runtimeConfig . public . auth , ( ) => getRequestURLWN ( nuxt ) )
63+ const redirectQueryParam = useRoute ( ) ?. query ?. redirect
64+ if ( redirectQueryParam ) {
65+ callbackUrl = redirectQueryParam . toString ( )
66+ }
67+ else {
68+ callbackUrl = await determineCallbackUrl ( runtimeConfig . public . auth , ( ) => getRequestURLWN ( nuxt ) )
69+ }
6470 }
6571 if ( redirect ) {
6672 return navigateTo ( callbackUrl , { external } )
0 commit comments