mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[AAE-12501] Trigger on login when token is received
This commit is contained in:
@@ -20,7 +20,7 @@ import { from, Observable, throwError, Subject } from 'rxjs';
|
|||||||
import { catchError, map, switchMap, filter, take } from 'rxjs/operators';
|
import { catchError, map, switchMap, filter, take } from 'rxjs/operators';
|
||||||
import { RepositoryInfo, SystemPropertiesRepresentation } from '@alfresco/js-api';
|
import { RepositoryInfo, SystemPropertiesRepresentation } from '@alfresco/js-api';
|
||||||
|
|
||||||
import { BpmProductVersionModel, AlfrescoApiService, AuthenticationService } from '@alfresco/adf-core';
|
import { BpmProductVersionModel, AuthenticationService } from '@alfresco/adf-core';
|
||||||
import { ApiClientsService } from '@alfresco/adf-core/api';
|
import { ApiClientsService } from '@alfresco/adf-core/api';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
@@ -34,13 +34,12 @@ export class DiscoveryApiService {
|
|||||||
ecmProductInfo$ = new Subject<RepositoryInfo>();
|
ecmProductInfo$ = new Subject<RepositoryInfo>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private apiService: AlfrescoApiService,
|
|
||||||
private authenticationService: AuthenticationService,
|
private authenticationService: AuthenticationService,
|
||||||
private apiClientsService: ApiClientsService
|
private apiClientsService: ApiClientsService
|
||||||
) {
|
) {
|
||||||
this.authenticationService.onLogin
|
this.authenticationService.onLogin
|
||||||
.pipe(
|
.pipe(
|
||||||
filter(() => this.apiService.getInstance()?.isEcmLoggedIn()),
|
filter(() => this.authenticationService.isEcmLoggedIn()),
|
||||||
take(1),
|
take(1),
|
||||||
switchMap(() => this.getEcmProductInfo())
|
switchMap(() => this.getEcmProductInfo())
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -46,6 +46,13 @@ export class OIDCAuthenticationService extends BaseAuthenticationService {
|
|||||||
private readonly auth: AuthService
|
private readonly auth: AuthService
|
||||||
) {
|
) {
|
||||||
super(alfrescoApi, appConfig, cookie, logService);
|
super(alfrescoApi, appConfig, cookie, logService);
|
||||||
|
this.alfrescoApi.alfrescoApiInitialized.subscribe(() => {
|
||||||
|
this.oauthService.events.pipe(
|
||||||
|
filter((event)=> event.type === 'token_received')
|
||||||
|
).subscribe(()=>{
|
||||||
|
this.onLogin.next();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
isEcmLoggedIn(): boolean {
|
isEcmLoggedIn(): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user