mirror of https://github.com/ghostfolio/ghostfolio
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
629 B
29 lines
629 B
import { Injectable } from '@angular/core';
|
|
|
|
const TOKEN_KEY = 'auth-token';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class TokenStorageService {
|
|
public constructor() {}
|
|
|
|
public getToken(): string {
|
|
return window.localStorage.getItem(TOKEN_KEY);
|
|
}
|
|
|
|
public saveToken(token: string): void {
|
|
window.localStorage.removeItem(TOKEN_KEY);
|
|
window.localStorage.setItem(TOKEN_KEY, token);
|
|
}
|
|
|
|
public signOut(): void {
|
|
const utmSource = window.localStorage.getItem('utm_source');
|
|
|
|
window.localStorage.clear();
|
|
|
|
if (utmSource) {
|
|
window.localStorage.setItem('utm_source', utmSource);
|
|
}
|
|
}
|
|
}
|
|
|