Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
b577d1f
feat: :sparkles: add flag to disable getSession after signIn on local…
bitfactory-frank-spee Mar 5, 2024
48deba6
feat: :sparkles: add flag to disable getSession after signIn on refre…
bitfactory-frank-spee Mar 5, 2024
3d10095
docs: :sparkles: add flag to disable getSession after signIn on local…
bitfactory-frank-spee Mar 5, 2024
681fdb0
fix: :bug: sync refresh provider redirect external with local provider
bitfactory-frank-spee Mar 5, 2024
e59026b
Merge branch 'main' into feature/optional-get-session-on-sign-in
bitfactory-frank-spee Apr 25, 2024
ac9415f
refactor: :recycle: rename withGetSession boolean to withSession
bitfactory-frank-spee Jun 7, 2024
695b437
Merge branch 'sidebase:main' into feature/optional-get-session-on-sig…
bitfactory-frank-spee Jun 7, 2024
14c2618
Merge branch 'main' into feature/optional-get-session-on-sign-in
bitfactory-frank-spee Nov 5, 2024
d77805e
docs: :memo: add example to disable getSession with signIn local prov…
bitfactory-frank-spee Nov 5, 2024
930aae3
feat: :label: add withSession flag to SecondarySignInOptions interface
bitfactory-frank-spee Nov 5, 2024
7739fbc
revert: style: :art: remove markdownlint md034 url change
bitfactory-frank-spee Nov 29, 2024
87f5838
docs: :memo: improve type documentation
bitfactory-frank-spee Nov 29, 2024
156fd57
refactor: :recycle: rename withSession to callGetSession
bitfactory-frank-spee Nov 29, 2024
d5c28ef
Merge branch 'feature/optional-get-session-on-sign-in' of https://git…
bitfactory-frank-spee Nov 29, 2024
32f3e80
Merge branch 'main' into feature/optional-get-session-on-sign-in
bitfactory-frank-spee Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/guide/application-side/session-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Time at which the session was last refreshed, either `undefined` if no refresh w

Returns the current Cross Site Request Forgery Token (CSRF Token) required to make POST requests (e.g. for signing in and signing out).

You likely only need to use this if you are not using the built-in `signIn()` and `signOut()` methods. Read more: https://next-auth.js.org/getting-started/client#getcsrftoken
You likely only need to use this if you are not using the built-in `signIn()` and `signOut()` methods. Read more: <https://next-auth.js.org/getting-started/client#getcsrftoken>
Comment thread
bitfactory-frank-spee marked this conversation as resolved.
Outdated

:::warning AuthJS Only
`getCsrfToken` is only avalible for the authjs provider!
Expand Down 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, { withSession: 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
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, withSession = true } = signInOptions ?? {}

if (withSession) {
Comment thread
phoenix-ru marked this conversation as resolved.
Outdated
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 @@ -548,6 +548,12 @@ export interface SecondarySignInOptions extends Record<string, unknown> {
* @default false
*/
external?: boolean
/**
* Whether `getSession` is called. If set to false, you have to manually call `getSession` to get the session data.
*
* @default true
*/
Comment thread
bitfactory-frank-spee marked this conversation as resolved.
withSession?: boolean
Comment thread
bitfactory-frank-spee marked this conversation as resolved.
Outdated
}

export interface SignUpOptions extends SecondarySignInOptions {
Comment thread
bitfactory-frank-spee marked this conversation as resolved.
Expand Down