This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| const routes: Routes = [ | |
| { | |
| path: '', | |
| pathMatch: 'full', | |
| component: HomeComponent | |
| }, | |
| { | |
| path: 'login', | |
| component: LoginComponent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <p> | |
| home works! | |
| </p> | |
| <button (click)="checkUserInfo()">Check userInfo</button> | |
| <pre>{{userInfo$ | async | json}}</pre> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ... | |
| export class TokenInterceptorService implements HttpInterceptor { | |
| static OidcInterceptorService: any; | |
| constructor(private oidcFacade: OidcFacade) {} | |
| intercept( | |
| req: HttpRequest<any>, | |
| next: HttpHandler | |
| ): Observable<HttpEvent<any>> { | |
| return this.oidcFacade.identity$.pipe( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| const routes: Routes = [ | |
| { | |
| path: '', | |
| pathMatch: 'full', | |
| component: HomeComponent | |
| }, | |
| { | |
| path: 'login', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| export class AuthGuard implements CanActivate { | |
| constructor(private router: Router, private oidcFacade: OidcFacade) {} | |
| public canActivate( | |
| route: ActivatedRouteSnapshot, | |
| state: RouterStateSnapshot | |
| ): Observable<boolean> | boolean { | |
| return this.oidcFacade.waitForAuthenticationLoaded().pipe( | |
| switchMap(loading => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <p> | |
| login works! | |
| </p> | |
| <button (click)="loginRedirect()">Login</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| export class LoginComponent implements OnInit { | |
| constructor(private oidcFacade: OidcFacade) {} | |
| ngOnInit() {} | |
| loginRedirect() { | |
| this.oidcFacade.signinRedirect(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| export class AppComponent implements OnInit { | |
| title = 'DraftApp'; | |
| identity$: Observable<User>; | |
| constructor(private oidcFacade: OidcFacade) { | |
| this.identity$ = this.oidcFacade.identity$; | |
| } | |
| ngOnInit() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <button routerLink="/">Home</button> | |
| <button routerLink="/protected">Protected</button> | |
| | |
| <button (click)="signoutRedirect()">Signout</button> | |
| <router-outlet></router-outlet> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div (click)="signinRedirect()"> | |
| Signin Redirect | |
| </div> | |
| <pre>{{identity$ | async | json}}</pre> | |
| <div (click)="signoutRedirect()"> | |
| Signout | |
| </div> | |
| <router-outlet></router-outlet> |