Skip to content

Commit

Permalink
Merge branch 'main' into docs/write-0-10-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix-ru authored Dec 19, 2024
2 parents ea51698 + b5af548 commit 3aac998
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
4 changes: 4 additions & 0 deletions docs/guide/application-side/session-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
```

:::
Expand Down Expand Up @@ -321,6 +324,7 @@ setToken('new token')
// Helper method to quickly delete the token cookie (alias for rawToken.value = null)
clearToken()
```

:::

:::warning Local provider:
Expand Down
20 changes: 16 additions & 4 deletions docs/guide/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,7 +31,7 @@ pnpm i -D @sidebase/nuxt-auth
```

```bash [yarn]
yarn add --dev @sidebase/nuxt-auth
yarn add -D @sidebase/nuxt-auth
```

:::
Expand All @@ -31,7 +43,7 @@ Add NuxtAuth to your `nuxt.config`:
```ts [nuxt.config.ts]
export default defineNuxtConfig({
modules: [
'@sidebase/nuxt-auth',
'@sidebase/nuxt-auth'
],
})
```
Expand Down
7 changes: 5 additions & 2 deletions src/runtime/composables/local/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ const signIn: SignInFunc<Credentials, any> = 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
Expand Down
6 changes: 6 additions & 0 deletions src/runtime/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,12 @@ export interface SecondarySignInOptions extends Record<string, unknown> {
* @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 {
Expand Down

0 comments on commit 3aac998

Please sign in to comment.