Properly logout of account

This commit is contained in:
Melon 2024-02-15 15:44:34 +00:00
parent f3d4b0e0a2
commit 48375db450
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
3 changed files with 8 additions and 1 deletions

View File

@ -58,7 +58,7 @@
on:click={() => { on:click={() => {
$loginStore = null; $loginStore = null;
localStorage.removeItem("login-session"); localStorage.removeItem("login-session");
localStorage.removeItem("pop2_access_token"); LOGIN.logout();
}} }}
> >
Logout Logout

View File

@ -10,6 +10,9 @@ export const LOGIN = {
init: () => { init: () => {
POP2.init(TOKEN_AUTHORIZE_API, OAUTH2_CLIENT_ID, "openid profile name", 500, 600); POP2.init(TOKEN_AUTHORIZE_API, OAUTH2_CLIENT_ID, "openid profile name", 500, 600);
}, },
logout: () => {
POP2.logout();
},
clientRequest: (resource: string, options: RequestInit, refresh: boolean) => { clientRequest: (resource: string, options: RequestInit, refresh: boolean) => {
return POP2.clientRequest(resource, options, refresh); return POP2.clientRequest(resource, options, refresh);
}, },

View File

@ -128,6 +128,10 @@ export const POP2 = (function (w) {
return true; return true;
} }
}, },
logout: function () {
access_token = "";
localStorage.removeItem("pop2_access_token");
},
clientRequest: function (resource, options, refresh = false) { clientRequest: function (resource, options, refresh = false) {
const sendRequest = function () { const sendRequest = function () {
options.credentials = "include"; options.credentials = "include";