Merge commit from fork

* fix(frontend): Improve cookie attributes

* fix(frontend): Delete an old authentication cookie in fetchAccount
This commit is contained in:
nexryai 2025-02-01 13:33:37 +09:00 committed by GitHub
parent f8f17a44d4
commit 77e421029c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -101,6 +101,9 @@ export async function removeAccount(idOrToken: Account['id']) {
} }
function fetchAccount(token: string, id?: string, forceShowDialog?: boolean): Promise<Account> { function fetchAccount(token: string, id?: string, forceShowDialog?: boolean): Promise<Account> {
document.cookie = "token=; path=/; max-age=0";
document.cookie = `token=${token}; path=/queue; max-age=86400; SameSite=Strict; Secure`; // bull dashboardの認証とかで使う
return new Promise((done, fail) => { return new Promise((done, fail) => {
window.fetch(`${apiUrl}/i`, { window.fetch(`${apiUrl}/i`, {
method: 'POST', method: 'POST',
@ -213,7 +216,6 @@ export async function login(token: Account['token'], redirect?: string) {
throw reason; throw reason;
}); });
miLocalStorage.setItem('account', JSON.stringify(me)); miLocalStorage.setItem('account', JSON.stringify(me));
document.cookie = `token=${token}; path=/; max-age=31536000`; // bull dashboardの認証とかで使う
await addAccount(me.id, token); await addAccount(me.id, token);
if (redirect) { if (redirect) {