mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-25 10:33:21 +03:00
Persist auth token
This commit is contained in:
parent
ba2d95a338
commit
253fc4ed62
@ -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<string | undefined>(undefined);
|
||||
#token = persisted<string | undefined>(undefined, 'AuthService--token');
|
||||
|
||||
constructor() {}
|
||||
|
||||
getToken() {
|
||||
return get(this.token);
|
||||
get token(): Readable<string | undefined> {
|
||||
return this.#token;
|
||||
}
|
||||
|
||||
setToken(data: string) {
|
||||
this.token.set(data);
|
||||
this.#token.set(data);
|
||||
}
|
||||
|
||||
clearToken() {
|
||||
this.token.set('');
|
||||
this.#token.set(undefined);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user