FarmMapsLib/projects/common/src/fm/components/auth-callback/auth-callback.component.ts

21 lines
701 B
TypeScript

import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { OAuthService } from 'angular-oauth2-oidc';
@Component({
selector: 'fm-auth-callback',
template:'<div></div>'
})
export class AuthCallbackComponent {
constructor(private router$: Router,private oauthService$:OAuthService) {
this.oauthService$.loadDiscoveryDocument().then(() => {
this.oauthService$.tryLoginCodeFlow().then(() => {
this.router$.navigateByUrl((this.oauthService$.state && this.oauthService$.state!="")?decodeURIComponent(this.oauthService$.state):"");
}).catch(() => {
this.router$.navigateByUrl("/");
});
})
}
}