From 253fc4ed62650c736914d13899983cf0bedb6caf Mon Sep 17 00:00:00 2001 From: Caleb Owens Date: Fri, 11 Oct 2024 12:04:11 +0200 Subject: [PATCH] Persist auth token --- apps/web/src/lib/auth/authService.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/web/src/lib/auth/authService.ts b/apps/web/src/lib/auth/authService.ts index 886ad4880..8d08cbe7d 100644 --- a/apps/web/src/lib/auth/authService.ts +++ b/apps/web/src/lib/auth/authService.ts @@ -1,19 +1,18 @@ -import { get, writable } from 'svelte/store'; +import { persisted } from '@gitbutler/shared/persisted'; +import { type Readable } from 'svelte/store'; export class AuthService { - token = writable(undefined); + #token = persisted(undefined, 'AuthService--token'); - constructor() {} - - getToken() { - return get(this.token); + get token(): Readable { + return this.#token; } setToken(data: string) { - this.token.set(data); + this.#token.set(data); } clearToken() { - this.token.set(''); + this.#token.set(undefined); } }