show effective account profile in sidebar
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
Configuration,
|
||||
IdToken,
|
||||
LoginResponse,
|
||||
AccountProfile,
|
||||
} from '../../api';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
|
||||
@@ -76,9 +77,7 @@ export class CredentialService {
|
||||
}
|
||||
|
||||
public validateCurrentSession(): Observable<void> {
|
||||
return this.httpClient
|
||||
.get(`${this.apiBasePath}/api/accounts/me`, { withCredentials: true })
|
||||
.pipe(map(() => undefined));
|
||||
return this.loadCurrentProfile();
|
||||
}
|
||||
|
||||
public requestOtk(email: string, password: string): Observable<string> {
|
||||
@@ -335,4 +334,19 @@ export class CredentialService {
|
||||
private get apiBasePath(): string {
|
||||
return this.apiConfiguration?.basePath ?? '';
|
||||
}
|
||||
|
||||
private loadCurrentProfile(): Observable<void> {
|
||||
return this.httpClient
|
||||
.get<AccountProfile>(`${this.apiBasePath}/api/accounts/me`, {
|
||||
withCredentials: true,
|
||||
})
|
||||
.pipe(
|
||||
tap((profile) => {
|
||||
this.login.next(profile.name ?? profile.email ?? '');
|
||||
this.email.next(profile.email ?? '');
|
||||
this.organizationName.next(profile.organization_name ?? '');
|
||||
}),
|
||||
map(() => undefined),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user