Overlay until log status received
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user