From cbafff3bb9dd1c3bce299a06b790a38ca7e5ecdb Mon Sep 17 00:00:00 2001 From: Lucio Maranta Date: Wed, 11 Sep 2019 16:05:28 +0200 Subject: [PATCH] Fix redirect after login --- .../src/app_modules/machine/components/login.ts | 13 ++++++++++--- Step/wwwroot/src/services/loginService.ts | 4 +--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Step/wwwroot/src/app_modules/machine/components/login.ts b/Step/wwwroot/src/app_modules/machine/components/login.ts index 0ab9c5ae..92e1bda2 100644 --- a/Step/wwwroot/src/app_modules/machine/components/login.ts +++ b/Step/wwwroot/src/app_modules/machine/components/login.ts @@ -37,9 +37,16 @@ export default class Login extends Vue { }) if(this.logginIn) { - if(userNotAuthorized) - this.$router.push('/production') - + if(userNotAuthorized){ + // If not authorized redirect to the first available page + for(var k in this.URLS_TO_FUNCTIONS_BINDING){ + if(machineStatusActions.isAreaVisible(store, this.URLS_TO_FUNCTIONS_BINDING[k])){ + this.$router.push(this.URLS_TO_FUNCTIONS_BINDING[k]) + break; + } + } + } + ModalHelper.HideModal("modal-login"); } } diff --git a/Step/wwwroot/src/services/loginService.ts b/Step/wwwroot/src/services/loginService.ts index 22963721..c436bb4a 100644 --- a/Step/wwwroot/src/services/loginService.ts +++ b/Step/wwwroot/src/services/loginService.ts @@ -1,7 +1,7 @@ import { baseRestService, AuthToken, to } from "src/_base/baseRestService"; import Factory from "src/_base/factoryService"; -import { store, appModelActions,machineStatusActions } from "src/store"; +import { store, appModelActions, machineStatusActions } from "src/store"; import { machineService } from "./machineService"; import {Hub} from "src/services/hub" @@ -9,8 +9,6 @@ import {Hub} from "src/services/hub" class LoginService extends baseRestService { public isAuthenticated: boolean = false; - $route: any; - $router: any; constructor() { super();