Open source personal finance application
fix: correct isDemo type, extract cookie max-age constant
Ilya Komichev74f06da381af
diff --git a/app/components/offline/replayHelpers.ts b/app/components/offline/replayHelpers.tsindex da7f4a88..17ca7a58 100644--- a/app/components/offline/replayHelpers.ts+++ b/app/components/offline/replayHelpers.ts@@ -279,8 +279,12 @@ export async function replayTrnOps(ops: OfflineOp[], remapIds: Map<string, strinif (isTrnOrphaned(remapped, context.walletsItems, context.categoriesItems)) {orphanCount++- try { await actions.removeOfflineOp(op.entity, op.id) }- catch (e) { logger.warn(`failed to remove orphan op ${op.entity}/${op.id}:`, e) }+ try {+ await actions.removeOfflineOp(op.entity, op.id)+ }+ catch (e) {+ logger.warn(`failed to remove orphan op ${op.entity}/${op.id}:`, e)+ }continue}diff --git a/app/components/user/useUserStore.ts b/app/components/user/useUserStore.tsindex 4c1df8e9..0ff1fb01 100644--- a/app/components/user/useUserStore.ts+++ b/app/components/user/useUserStore.ts@@ -177,7 +177,7 @@ export const useUserStore = defineStore('user', () => {if (isDemo.value) {await localforage.clear()- isDemo.value = null+ isDemo.value = undefinedclearAuthCookie()setSessionInitialized(false)window.location.href = '/login'diff --git a/app/composables/useAuthCookie.ts b/app/composables/useAuthCookie.tsindex 81f00814..cf4002fd 100644--- a/app/composables/useAuthCookie.ts+++ b/app/composables/useAuthCookie.ts@@ -15,7 +15,8 @@ export function hasAuthCookie(): boolean {const secureSuffix = globalThis.location?.protocol === 'https:' ? ';Secure' : ''export function setAuthCookie(uid: string) {- document.cookie = `finapp.localAuthUid=${encodeURIComponent(uid)};path=/;max-age=31536000;SameSite=Lax${secureSuffix}`+ const ONE_YEAR = 60 * 60 * 24 * 365+ document.cookie = `finapp.localAuthUid=${encodeURIComponent(uid)};path=/;max-age=${ONE_YEAR};SameSite=Lax${secureSuffix}`}export function clearAuthCookie() {