From f2a716624485f9d3f8c8f64ca04cf07a7e3a9bc1 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Wed, 20 Jan 2016 14:54:59 -0800 Subject: [PATCH] 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` --- src/app/LoggedInOutlet.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/LoggedInOutlet.ts b/src/app/LoggedInOutlet.ts index 7c70d51..508aa75 100644 --- a/src/app/LoggedInOutlet.ts +++ b/src/app/LoggedInOutlet.ts @@ -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');