Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 2beae4f

Browse files
committed
Add secured/unsecured navbar. Add instructions on how to test Values API Component.
1 parent 33e6193 commit 2beae4f

File tree

5 files changed

+44
-19
lines changed

5 files changed

+44
-19
lines changed

src/app/app.component.html

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
<h3>
2-
Angular 2 Seed
2+
Angular/Adal.js Seed
33
</h3>
4-
<nav>
5-
<a [routerLink]="['/']">
4+
5+
<nav id="unsecured-nav" *ngIf="!adalService.userInfo">
6+
<a [routerLink]="['/']">
67
Login
7-
</a>
8+
</a>
89
|
9-
<a [routerLink]="['/home']">
10-
Home
11-
</a>
12-
|
13-
<a [routerLink]="['/about']">
10+
<a [routerLink]="['/about']">
1411
About
15-
</a>
12+
</a>
1613
|
17-
<a [routerLink]="['/github', 'angular']">
18-
Github Repos
14+
<a [routerLink]="['/contact']">
15+
Contact Us
1916
</a>
17+
</nav>
18+
19+
<nav id="secured-nav" *ngIf="adalService.userInfo">
20+
<a [routerLink]="['/home']">
21+
Home
22+
</a>
2023
|
21-
<a [routerLink]="['/contact']">
22-
Contact Us
24+
<a [routerLink]="['/values']">
25+
Values API
2326
</a>
2427
</nav>
2528

2629
<main>
27-
<router-outlet></router-outlet>
30+
<router-outlet></router-outlet>
2831
</main>
2932

30-
33+
<br />
3134
<footer>
3235
© 2016
33-
</footer>
36+
</footer>

src/app/app.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import { AdalService } from './services/adal.service';
12
import {Component} from '@angular/core';
23

34
@Component({
45
selector: 'app',
56
templateUrl: './app.component.html',
67
})
78
export class AppComponent {
9+
constructor(private adalService: AdalService){
10+
11+
}
812
}

src/app/home/home.component.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
<h3>Home Component</h3>
2-
<p>Welcome to Angular Seed</p>
2+
<h2>Welcome {{adalService.userInfo.userName}}!</h2>
3+
4+
<div *ngIf="isLoggedIn">
5+
<button (click)="logout()">Logout</button>
6+
</div>
7+
<br>

src/app/home/home.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,12 @@ export class HomeComponent {
1313
console.log('JWT Token');
1414
console.log(this.adalService.accessToken);
1515
}
16+
17+
logout() {
18+
this.adalService.logout();
19+
}
20+
21+
public get isLoggedIn() {
22+
return this.adalService.isAuthenticated;
23+
}
1624
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
<h2>Values from ValueController</h2>
21

2+
<h3>
3+
<p>In order to test this component, you must run the API located <a href="https://github.com/vsaroopchand/angular2-seed-server">here</a>.</p>
4+
<p>This demonstrates how to pass the JWT token to a WebAPI and revalidating it there.</p>
5+
</h3>
6+
7+
<h2>Values from ValueController</h2>
38
<ul>
49
<li *ngFor="let value of values$ | async">{{value}}</li>
510
</ul>

0 commit comments

Comments
 (0)