This is part of the app.component. Below is the router outlet.
16 |You can go to a url without a route to see the fallback route.
20 |22 | 23 | 24 | 25 |
26 |27 | 28 | 29 | 30 |
31 |IsAuthenticated | {{isAuthenticated$ | async}} |
---|---|
HasValidToken | {{hasValidToken}} |
IsDoneLoading | {{isDoneLoading$ | async}} |
CanActivateProtectedRoutes | {{canActivateProtectedRoutes$ | async}} |
IdentityClaims | {{identityClaims | json}} |
RefreshToken | {{refreshToken}} |
AccessToken | {{accessToken}} |
IdToken | {{idToken}} |
This is the 🕳️ FALLBACK component.
`, 6 | standalone: false 7 | }) 8 | export class FallbackComponent { 9 | } 10 | -------------------------------------------------------------------------------- /src/app/feature-basics/admin1.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { Observable } from 'rxjs'; 3 | 4 | import { ApiService } from '../shared/api.service'; 5 | 6 | @Component({ 7 | selector: 'app-admin', 8 | template: `9 | This is the ⚙ ADMIN component. 10 | It will not redirect you to the login server. 11 | - {{ apiResponse | async }} 12 |
`, 13 | standalone: false 14 | }) 15 | export class Admin1Component implements OnInit { 16 | apiResponse!: Observable9 | This is the 🏠 HOME component. 10 | - {{ apiResponse | async }} 11 |
`, 12 | standalone: false 13 | }) 14 | export class HomeComponent implements OnInit { 15 | apiResponse!: ObservableThis is the 🌐 PUBLIC component.
`, 6 | standalone: false 7 | }) 8 | export class PublicComponent { 9 | } 10 | -------------------------------------------------------------------------------- /src/app/feature-extras/admin2.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { Observable } from 'rxjs'; 3 | 4 | import { ApiService } from '../shared/api.service'; 5 | 6 | @Component({ 7 | selector: 'app-admin', 8 | template: `9 | This is the 🔧 ADMIN 2 component. 10 | It will redirect you to login if needed. 11 | - {{ apiResponse | async }} 12 |
`, 13 | standalone: false 14 | }) 15 | export class Admin2Component implements OnInit { 16 | apiResponse!: ObservableYou need to be logged in to view requested page.
7 |Please log in before continuing.
`, 8 | standalone: false 9 | }) 10 | export class ShouldLoginComponent { 11 | constructor(private authService: OAuthService) { } 12 | 13 | public login($event: any) { 14 | $event.preventDefault(); 15 | this.authService.initLoginFlow(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeroenheijmans/sample-angular-oauth2-oidc-with-auth-guards/3c4b0faf062ca438e56b771e2cc9ca0680a1b485/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * In development mode, to ignore zone related error stack frames such as 11 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can 12 | * import the following file, but please comment it out in production mode 13 | * because it will have performance impact when throw error 14 | */ 15 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 16 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeroenheijmans/sample-angular-oauth2-oidc-with-auth-guards/3c4b0faf062ca438e56b771e2cc9ca0680a1b485/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |