From 09a6775746f219e7c5b329607fe0a5719fba7828 Mon Sep 17 00:00:00 2001 From: Pascal Jufer Date: Sun, 10 Mar 2024 18:59:06 +0100 Subject: [PATCH] Fix logout SDK auth composable to include auth mode (#21793) * Fix logout of SDK auth composable to include mode * Add changeset * Update sdk/src/auth/composable.ts * stricter type in refresh --------- Co-authored-by: Brainslug Co-authored-by: Brainslug --- .changeset/nine-coins-pull.md | 5 +++++ sdk/src/auth/composable.ts | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .changeset/nine-coins-pull.md diff --git a/.changeset/nine-coins-pull.md b/.changeset/nine-coins-pull.md new file mode 100644 index 0000000000..ca5a724906 --- /dev/null +++ b/.changeset/nine-coins-pull.md @@ -0,0 +1,5 @@ +--- +'@directus/sdk': patch +--- + +Fixed logout SDK auth composable to include auth mode in request diff --git a/sdk/src/auth/composable.ts b/sdk/src/auth/composable.ts index 1bc0b0beb7..c1045e6b08 100644 --- a/sdk/src/auth/composable.ts +++ b/sdk/src/auth/composable.ts @@ -88,7 +88,7 @@ export const authentication = (mode: AuthenticationMode = 'cookie', config: Part fetchOptions.credentials = authConfig.credentials; } - const body: Record = { mode }; + const body: Record = { mode }; if (mode === 'json' && authData?.refresh_token) { body['refresh_token'] = authData.refresh_token; @@ -154,12 +154,14 @@ export const authentication = (mode: AuthenticationMode = 'cookie', config: Part fetchOptions.credentials = authConfig.credentials; } + const body: Record = { mode }; + if (mode === 'json' && authData?.refresh_token) { - fetchOptions.body = JSON.stringify({ - refresh_token: authData.refresh_token, - }); + body['refresh_token'] = authData.refresh_token; } + fetchOptions.body = JSON.stringify(body); + const requestUrl = getRequestUrl(client.url, '/auth/logout'); await request(requestUrl.toString(), fetchOptions, client.globals.fetch);