fix: logout using custom logout endpoint

This commit is contained in:
thecodrr
2021-01-04 11:22:24 +05:00
parent 307c49c718
commit a2c3ca4b82

View File

@@ -5,6 +5,7 @@ const ENDPOINTS = {
token: "/connect/token", token: "/connect/token",
revoke: "/connect/revocation", revoke: "/connect/revocation",
temporaryToken: "/account/token", temporaryToken: "/account/token",
logout: "/account/logout",
}; };
class TokenManager { class TokenManager {
@@ -54,19 +55,13 @@ class TokenManager {
async revokeToken() { async revokeToken() {
const token = await this.getToken(); const token = await this.getToken();
if (!token) return; if (!token) return;
const { access_token, refresh_token } = token; const { access_token } = token;
await http.post(`${constants.AUTH_HOST}${ENDPOINTS.revoke}`, { await http.post(
token: access_token, `${constants.AUTH_HOST}${ENDPOINTS.logout}`,
client_id: "notesnook", null,
token_type_hint: "access_token", access_token
}); );
await http.post(`${constants.AUTH_HOST}${ENDPOINTS.revoke}`, {
token: refresh_token,
client_id: "notesnook",
token_type_hint: "refresh_token",
});
} }
saveToken(tokenResponse) { saveToken(tokenResponse) {