Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ add flag to disable getSession after signIn on local / refresh provider #702

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
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
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 @@ -563,6 +563,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 {
bitfactory-frank-spee marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading