diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-09-30 22:42:46 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-09-30 22:42:46 +0700 |
| commit | 011c01a741f23734e4154342e9a560925687f152 (patch) | |
| tree | d874ad11b52eb9749a53af5d90958e3a76f219c0 /app/lib/api/clearOdooSession.ts | |
| parent | 352000c186a2765416cd2fab6693e68bb62e9e53 (diff) | |
<Miqdad> No auto loginrole
Diffstat (limited to 'app/lib/api/clearOdooSession.ts')
| -rw-r--r-- | app/lib/api/clearOdooSession.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/lib/api/clearOdooSession.ts b/app/lib/api/clearOdooSession.ts new file mode 100644 index 0000000..0ad9a5d --- /dev/null +++ b/app/lib/api/clearOdooSession.ts @@ -0,0 +1,25 @@ +export async function clearOdooSession(baseUrl: string) { + try { + if (baseUrl) { + await fetch(`${baseUrl}/web/session/destroy`, { + method: "POST", + credentials: "include", + headers: { "Content-Type": "application/json" }, + body: "{}", + }); + } + } catch { } + + // 2) hapus cookie session_id di browser + try { + const del = (name: string, domain?: string) => { + const d = domain ? `; domain=${domain}` : ""; + document.cookie = `${name}=; Max-Age=0; Path=/${d}`; + document.cookie = `${name}=; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/${d}`; + }; + const host = window.location.hostname.replace(/^www\./, ""); + const parts = host.split("."); + const parent = parts.length >= 2 ? `.${parts.slice(-2).join(".")}` : undefined; + [undefined, host, parent].forEach(dom => del("session_id", dom)); + } catch { } +} |
