diff --git a/docs/guide/application-side/session-access.md b/docs/guide/application-side/session-access.md index 90cd821c..0d89c80c 100644 --- a/docs/guide/application-side/session-access.md +++ b/docs/guide/application-side/session-access.md @@ -210,6 +210,9 @@ await signIn(credentials, { callbackUrl: '/protected' }) // Trigger a signIn with a redirect to an external page afterwards await signIn(credentials, { callbackUrl: 'https://nuxt.org', external: true }) + +// Trigger a signIn without calling getSession directly. You have to manually call it to get session data. +await signIn(credentials, { callGetSession: false }) ``` ::: @@ -321,6 +324,7 @@ setToken('new token') // Helper method to quickly delete the token cookie (alias for rawToken.value = null) clearToken() ``` + ::: :::warning Local provider: diff --git a/docs/guide/getting-started/installation.md b/docs/guide/getting-started/installation.md index 20283adb..7fde490a 100644 --- a/docs/guide/getting-started/installation.md +++ b/docs/guide/getting-started/installation.md @@ -2,10 +2,22 @@ You can install NuxtAuth using nuxi: -```bash -npx nuxi@latest module add sidebase-auth +::: code-group + +```bash [npm] +npx nuxi module add sidebase-auth +``` + +```bash [pnpm] +pnpm exec nuxi module add sidebase-auth ``` +```bash [yarn] +yarn dlx nuxi module add sidebase-auth +``` + +::: + ::: details Manual installation ::: code-group @@ -19,7 +31,7 @@ pnpm i -D @sidebase/nuxt-auth ``` ```bash [yarn] -yarn add --dev @sidebase/nuxt-auth +yarn add -D @sidebase/nuxt-auth ``` ::: @@ -31,7 +43,7 @@ Add NuxtAuth to your `nuxt.config`: ```ts [nuxt.config.ts] export default defineNuxtConfig({ modules: [ - '@sidebase/nuxt-auth', + '@sidebase/nuxt-auth' ], }) ``` diff --git a/src/runtime/composables/local/useAuth.ts b/src/runtime/composables/local/useAuth.ts index c24ac87b..c122262c 100644 --- a/src/runtime/composables/local/useAuth.ts +++ b/src/runtime/composables/local/useAuth.ts @@ -55,9 +55,12 @@ const signIn: SignInFunc = async (credentials, signInOptions, rawRefreshToken.value = extractedRefreshToken } - await nextTick(getSession) + const { redirect = true, external, callGetSession = true } = signInOptions ?? {} + + if (callGetSession) { + await nextTick(getSession) + } - const { redirect = true, external } = signInOptions ?? {} let { callbackUrl } = signInOptions ?? {} if (typeof callbackUrl === 'undefined') { const redirectQueryParam = useRoute()?.query?.redirect diff --git a/src/runtime/types.ts b/src/runtime/types.ts index 9b037855..e94c1707 100644 --- a/src/runtime/types.ts +++ b/src/runtime/types.ts @@ -574,6 +574,12 @@ export interface SecondarySignInOptions extends Record { * @default false */ external?: boolean + /** + * Whether `getSession` needs to be called after a successful sign-in. When set to false, you can manually call `getSession` to obtain the session data. + * + * @default true + */ + callGetSession?: boolean } export interface SignUpOptions extends SecondarySignInOptions {