From ba9f295ef2bf31cc90fa587e20b9a7655b7a1824 Mon Sep 17 00:00:00 2001
From: Sung Jae Lee <cocoa@hoto.us>
Date: Sat, 1 Feb 2025 13:35:42 +0900
Subject: [PATCH] Merge commit from fork
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* fix(account): clear token cookie when signout called

* fix: cookie not cleared correctly when logout

Co-authored-by: おさむのひと <46447427+samunohito@users.noreply.github.com>

* feat: clear only token cookie when signout

---------

Co-authored-by: おさむのひと <46447427+samunohito@users.noreply.github.com>
---
 packages/frontend/src/account.ts | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/packages/frontend/src/account.ts b/packages/frontend/src/account.ts
index 2f9a887720..9006150bc8 100644
--- a/packages/frontend/src/account.ts
+++ b/packages/frontend/src/account.ts
@@ -41,6 +41,12 @@ export async function signout() {
 	if (!$i) return;
 
 	waiting();
+	document.cookie.split(';').forEach((cookie) => {
+		const cookieName = cookie.split('=')[0].trim();
+		if (cookieName === 'token') {
+			document.cookie = `${cookieName}=; max-age=0; path=/`;
+		}
+	});
 	miLocalStorage.removeItem('account');
 	await removeAccount($i.id);
 	const accounts = await getAccounts();