Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"@angular/platform-browser": "~8.0.1",
"@angular/platform-browser-dynamic": "~8.0.1",
"@angular/router": "~8.0.1",
"angular-crypto-js": "^1.0.7",
"crypto-js": "^4.0.0",
"rxjs": "~6.4.0",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
Expand All @@ -45,4 +47,4 @@
"tslint": "~5.15.0",
"typescript": "~3.4.3"
}
}
}
5 changes: 3 additions & 2 deletions src/app/_helpers/fake-backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { HttpRequest, HttpResponse, HttpHandler, HttpEvent, HttpInterceptor, HTTP_INTERCEPTORS } from '@angular/common/http';
import { Observable, of, throwError } from 'rxjs';
import { delay, mergeMap, materialize, dematerialize } from 'rxjs/operators';
import sha256 from 'crypto-js/sha256';

import { User } from '@app/_models';

Expand Down Expand Up @@ -42,7 +43,7 @@ export class FakeBackendInterceptor implements HttpInterceptor {
username: user.username,
firstName: user.firstName,
lastName: user.lastName,
token: 'fake-jwt-token'
token: sha256('fake-jwt-token')
})
}

Expand All @@ -66,7 +67,7 @@ export class FakeBackendInterceptor implements HttpInterceptor {
}

function isLoggedIn() {
return headers.get('Authorization') === 'Bearer fake-jwt-token';
return headers.get('Authorization') === 'Bearer '+sha256('fake-jwt-token');
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ <h4 class="card-header">You're logged in with Angular 8 & JWT!!</h4>
<h6>Users from secure api end point</h6>
<div *ngIf="loading" class="spinner-border spinner-border-sm"></div>
<ul *ngIf="users">
<li *ngFor="let user of users">{{user.firstName}} {{user.lastName}}</li>
<li *ngFor="let user of users">{{user.id}}. {{user.firstName}} {{user.lastName}}</li>
</ul>
</div>
<div class="card-body">
<h3>Information</h3>
</div>
</div>
1 change: 1 addition & 0 deletions src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class HomeComponent {
this.userService.getAll().pipe(first()).subscribe(users => {
this.loading = false;
this.users = users;
console.log(this.users)
});
}
}