mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-25 18:49:11 +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 {
|
export class AuthService {
|
||||||
token = writable<string | undefined>(undefined);
|
#token = persisted<string | undefined>(undefined, 'AuthService--token');
|
||||||
|
|
||||||
constructor() {}
|
get token(): Readable<string | undefined> {
|
||||||
|
return this.#token;
|
||||||
getToken() {
|
|
||||||
return get(this.token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setToken(data: string) {
|
setToken(data: string) {
|
||||||
this.token.set(data);
|
this.#token.set(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearToken() {
|
clearToken() {
|
||||||
this.token.set('');
|
this.#token.set(undefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user