Skip to content
Merged
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
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`
  • Loading branch information
Matthew Miller committed Jan 20, 2016
commit f2a716624485f9d3f8c8f64ca04cf07a7e3a9bc1
7 changes: 4 additions & 3 deletions src/app/LoggedInOutlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ export class LoggedInRouterOutlet extends RouterOutlet {
super(_elementRef, _loader, _parentRouter, nameAttr);

this.parentRouter = _parentRouter;
// The Boolean following each route below denotes whether the route requires authentication to view
this.publicRoutes = {
'/login': true,
'/signup': true
'login': true,
'signup': true
};
}

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