summaryrefslogtreecommitdiff
path: root/app/lib
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2025-10-01 10:07:28 +0000
committerIT Fixcomart <it@fixcomart.co.id>2025-10-01 10:07:28 +0000
commitd4688ee0f8590e54211548dd1cfd0faec87d04d0 (patch)
treed874ad11b52eb9749a53af5d90958e3a76f219c0 /app/lib
parent0626907b555ead7991d03c374edc096254aced8d (diff)
parent011c01a741f23734e4154342e9a560925687f152 (diff)
Merged in role (pull request #3)
<Miqdad> Major change: adding Role
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/api/clearOdooSession.ts25
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 { }
+}