Overlay until log status received

This commit is contained in:
Eneko Nieto
2021-02-13 00:37:10 +01:00
parent e9d5ce4d8e
commit 77497a642d
12 changed files with 172 additions and 99 deletions

View File

@@ -1,35 +1,21 @@
import { Component } from '@angular/core';
import { OAuthService, NullValidationHandler } from 'angular-oauth2-oidc';
import { Router } from '@angular/router';
import { filter } from 'rxjs/operators';
import { authConfig } from './auth.config';
import { useHash } from '../flags';
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { AuthService } from './services/auth.service';
@Component({
// tslint:disable-next-line:component-selector
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
constructor(private router: Router, private oauthService: OAuthService) {
this.configureCodeFlow();
export class AppComponent implements OnInit {
showOverlay = true;
// Automatically load user profile
this.oauthService.events
.pipe(filter((e) => e.type === 'token_received'))
.subscribe((_) => {
console.log('state', this.oauthService.state);
this.oauthService.loadUserProfile();
});
}
constructor(
private authService: AuthService
) { }
private configureCodeFlow(): void {
this.oauthService.configure(authConfig);
this.oauthService.loadDiscoveryDocumentAndTryLogin().then((_) => {
if (useHash) {
this.router.navigate(['/']);
}
});
this.oauthService.setupAutomaticSilentRefresh();
async ngOnInit(): Promise<void> {
await this.authService.isLogged;
this.showOverlay = false;
}
}