Skip to content

Commit f2a7166

Browse files
author
Matthew Miller
committed
Update LoggedInOutlet.ts
- Updated `activate()` to handle a bug that enabled access to non-public routes after loading a public route - Updated `publicRoutes` to reflect values returned by `ComponentInstruction.urlPath` - Added a small comment clarifying the purpose of the boolean assigned to each route in `publicRoutes`
1 parent 7f9b43d commit f2a7166

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/app/LoggedInOutlet.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ export class LoggedInRouterOutlet extends RouterOutlet {
1414
super(_elementRef, _loader, _parentRouter, nameAttr);
1515

1616
this.parentRouter = _parentRouter;
17+
// The Boolean following each route below denotes whether the route requires authentication to view
1718
this.publicRoutes = {
18-
'/login': true,
19-
'/signup': true
19+
'login': true,
20+
'signup': true
2021
};
2122
}
2223

2324
activate(instruction: ComponentInstruction) {
24-
var url = this.parentRouter.lastNavigationAttempt;
25+
let url = instruction.urlPath;
2526
if (!this.publicRoutes[url] && !localStorage.getItem('jwt')) {
2627
// todo: redirect to Login, may be there a better way?
2728
this.parentRouter.navigateByUrl('/login');

0 commit comments

Comments
 (0)