Skip to content

Commit

Permalink
feat: add possibility to disable signOut endpoint for local provider (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
anjarupnik authored Nov 16, 2023
1 parent 24c31b8 commit 64e9001
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/content/2.configuration/2.nuxt-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ type ProviderLocal = {
*/
signIn?: { path?: string, method?: RouterMethod },
/**
* What method and path to call to perform the sign-out.
* What method and path to call to perform the sign-out. Set to false to disable.
*
* @default { path: '/logout', method: 'post' }
*/
signOut?: { path?: string, method?: RouterMethod },
signOut?: { path?: string, method?: RouterMethod } | false,
/**
* What method and path to call to perform the sign-up.
*
Expand Down
8 changes: 6 additions & 2 deletions src/runtime/composables/local/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ const signOut: SignOutFunc = async (signOutOptions) => {
data.value = null
rawToken.value = null

const { path, method } = config.endpoints.signOut
const signOutConfig = config.endpoints.signOut
let res

const res = await _fetch(nuxt, path, { method, headers })
if (signOutConfig) {
const { path, method } = signOutConfig
res = await _fetch(nuxt, path, { method, headers })
}

const { callbackUrl, redirect = true, external } = signOutOptions ?? {}
if (redirect) {
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ type ProviderLocal = {
*/
signIn?: { path?: string, method?: RouterMethod },
/**
* What method and path to call to perform the sign-out.
* What method and path to call to perform the sign-out. Set to false to disable.
*
* @default { path: '/logout', method: 'post' }
*/
signOut?: { path?: string, method?: RouterMethod },
signOut?: { path?: string, method?: RouterMethod } | false,
/**
* What method and path to call to perform the sign-up.
*
Expand Down

0 comments on commit 64e9001

Please sign in to comment.