diff --git a/webapp/src/app/shared/services/credential.service.ts b/webapp/src/app/shared/services/credential.service.ts index ed9134fa..8e72953f 100644 --- a/webapp/src/app/shared/services/credential.service.ts +++ b/webapp/src/app/shared/services/credential.service.ts @@ -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 { - return this.httpClient - .get(`${this.apiBasePath}/api/accounts/me`, { withCredentials: true }) - .pipe(map(() => undefined)); + return this.loadCurrentProfile(); } public requestOtk(email: string, password: string): Observable { @@ -335,4 +334,19 @@ export class CredentialService { private get apiBasePath(): string { return this.apiConfiguration?.basePath ?? ''; } + + private loadCurrentProfile(): Observable { + return this.httpClient + .get(`${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), + ); + } }