|
|
@ -1,3 +1,4 @@ |
|
|
|
|
|
import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service'; |
|
|
import { Filter, User } from '@ghostfolio/common/interfaces'; |
|
|
import { Filter, User } from '@ghostfolio/common/interfaces'; |
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
|
|
|
|
|
|
@ -26,7 +27,8 @@ export class UserService extends ObservableStore<UserStoreState> { |
|
|
public constructor( |
|
|
public constructor( |
|
|
private deviceService: DeviceDetectorService, |
|
|
private deviceService: DeviceDetectorService, |
|
|
private dialog: MatDialog, |
|
|
private dialog: MatDialog, |
|
|
private http: HttpClient |
|
|
private http: HttpClient, |
|
|
|
|
|
private webAuthnService: WebAuthnService |
|
|
) { |
|
|
) { |
|
|
super({ trackStateHistory: true }); |
|
|
super({ trackStateHistory: true }); |
|
|
|
|
|
|
|
|
@ -93,10 +95,40 @@ export class UserService extends ObservableStore<UserStoreState> { |
|
|
return this.getFilters().length > 0; |
|
|
return this.getFilters().length > 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public remove() { |
|
|
public reset() { |
|
|
this.setState({ user: null }, UserStoreActions.RemoveUser); |
|
|
this.setState({ user: null }, UserStoreActions.RemoveUser); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public signOut() { |
|
|
|
|
|
const utmSource = window.localStorage.getItem('utm_source'); |
|
|
|
|
|
|
|
|
|
|
|
if (this.webAuthnService.isEnabled()) { |
|
|
|
|
|
this.webAuthnService.deregister().subscribe(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
window.localStorage.clear(); |
|
|
|
|
|
window.sessionStorage.clear(); |
|
|
|
|
|
|
|
|
|
|
|
void this.clearAllCookies(); |
|
|
|
|
|
|
|
|
|
|
|
this.reset(); |
|
|
|
|
|
|
|
|
|
|
|
if (utmSource) { |
|
|
|
|
|
window.localStorage.setItem('utm_source', utmSource); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async clearAllCookies() { |
|
|
|
|
|
if (!('cookieStore' in window)) { |
|
|
|
|
|
console.warn('Cookie Store API not available in this browser'); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const cookies = await cookieStore.getAll(); |
|
|
|
|
|
|
|
|
|
|
|
await Promise.all(cookies.map(({ name }) => cookieStore.delete(name))); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private fetchUser(): Observable<User> { |
|
|
private fetchUser(): Observable<User> { |
|
|
return this.http.get<any>('/api/v1/user').pipe( |
|
|
return this.http.get<any>('/api/v1/user').pipe( |
|
|
map((user) => { |
|
|
map((user) => { |
|
|
|