Incluido angular-oauth2-oidc en app-component
This commit is contained in:
@@ -1,37 +1,40 @@
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
|
||||
import { AuthService, AuthState } from './services/auth.service';
|
||||
import { OidcSecurityService } from 'angular-auth-oidc-client';
|
||||
|
||||
@Component({
|
||||
// tslint:disable-next-line:component-selector
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.css'],
|
||||
styleUrls: ['./app.component.css']
|
||||
})
|
||||
export class AppComponent implements OnInit, OnDestroy {
|
||||
showOverlay = true;
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private authService: AuthService,
|
||||
private oidcSecurityService: OidcSecurityService,
|
||||
// private authService: AuthService,
|
||||
private router: Router
|
||||
) { }
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
console.log('AppComponent.ngInit()');
|
||||
|
||||
const chatLoginToken = await this.waitChatToken();
|
||||
const authState = await this.authService.configureAndTryLogin(chatLoginToken);
|
||||
this.oidcSecurityService.checkAuth().subscribe((auth) => console.log('is authenticated', auth));
|
||||
|
||||
if (authState !== AuthState.ChatLoggingInProcess) {
|
||||
// const chatLoginToken = await this.waitChatToken();
|
||||
// const authState = await this.authService.configureAndTryLogin(chatLoginToken);
|
||||
|
||||
// if (authState !== AuthState.ChatLoggingInProcess) {
|
||||
this.showOverlay = false;
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
// TODO no se ejecuta
|
||||
console.log('AppComponent.ngDestroy()');
|
||||
this.authService.stopAutomaticRefresh();
|
||||
// this.authService.stopAutomaticRefresh();
|
||||
}
|
||||
|
||||
private async waitChatToken(): Promise<string> {
|
||||
|
||||
Reference in New Issue
Block a user