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 <br41nslug@users.noreply.github.com>
Co-authored-by: Brainslug <tim@brainslug.nl>
This commit is contained in:
Pascal Jufer
2024-03-10 18:59:06 +01:00
committed by GitHub
parent 2e259d07cd
commit 09a6775746
2 changed files with 11 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
'@directus/sdk': patch
---
Fixed logout SDK auth composable to include auth mode in request

View File

@@ -88,7 +88,7 @@ export const authentication = (mode: AuthenticationMode = 'cookie', config: Part
fetchOptions.credentials = authConfig.credentials;
}
const body: Record<string, any> = { mode };
const body: Record<string, string> = { 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<string, string> = { 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);