From aa14189531d999a937b0a7361b9a1a5154a62a20 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Mon, 13 Aug 2018 21:37:53 -0700 Subject: [PATCH] Redirect to login when not authorized --- client/app.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/app.js b/client/app.js index fef3830..11069ab 100644 --- a/client/app.js +++ b/client/app.js @@ -11,6 +11,7 @@ import * as devicePage from "./device-page"; import * as errorPage from "./error-page"; import * as faultsPage from "./faults-page"; import Authorizer from "../common/authorizer"; +import * as notifications from "./notifications"; window.authorizer = new Authorizer(window.permissionSets); @@ -41,7 +42,7 @@ function pagify(pageName, page) { } }; - component.onmatch = args => { + component.onmatch = (args, requestedPath) => { pageVisitTimestamp = Date.now(); if (!page.init) { state = null; @@ -59,6 +60,10 @@ function pagify(pageName, page) { fulfill(); }) .catch(err => { + if (!window.username && err.message.indexOf("authorized") >= 0) { + notifications.push("error", err.message); + m.route.set("/login", { continue: requestedPath }); + } state = { error: err.message }; resolve(); });