From 152cb381ea2c915c762416092337ce1d8589d1c6 Mon Sep 17 00:00:00 2001 From: Aijana Schumann Date: Mon, 6 Dec 2021 15:09:15 +0100 Subject: Update ODLUX Update login view, add logout after user session ends, add user settings, several bugfixes Issue-ID: CCSDK-3540 Signed-off-by: Aijana Schumann Change-Id: I21137756b204287e25766a9646bf2faf7bad9d35 --- sdnr/wt/odlux/framework/src/middleware/navigation.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'sdnr/wt/odlux/framework/src/middleware/navigation.ts') diff --git a/sdnr/wt/odlux/framework/src/middleware/navigation.ts b/sdnr/wt/odlux/framework/src/middleware/navigation.ts index c5ab788f3..94350ab5d 100644 --- a/sdnr/wt/odlux/framework/src/middleware/navigation.ts +++ b/sdnr/wt/odlux/framework/src/middleware/navigation.ts @@ -24,7 +24,7 @@ import { LocationChanged, NavigateToApplication } from "../actions/navigationAct import { PushAction, ReplaceAction, GoAction, GoBackAction, GoForwardeAction } from '../actions/navigationActions'; import { applicationManager } from "../services/applicationManager"; -import { UpdateUser } from "../actions/authentication"; +import { loginUserAction, logoutUser } from "../actions/authentication"; import { ApplicationStore } from "../store/applicationStore"; import { Dispatch } from '../flux/store'; @@ -59,12 +59,17 @@ const routerMiddlewareCreator = (history: History) => () => (next: Dispatch): Di const token = tokenStr && jwt.decode(tokenStr); if (tokenStr && token) { // @ts-ignore - const user = new User({ username: token["name"], access_token: tokenStr, token_type: "Bearer", expires: (new Date().valueOf()) + ( (+token['exp']) * 1000) }) || undefined; - return next(new UpdateUser(user)) as any; + const user = new User({ username: token["name"], access_token: tokenStr, token_type: "Bearer", expires: token['exp'], issued: token['iat'] }) || undefined; + return next(loginUserAction(user)) as any; } } if (!action.pathname.startsWith("/login") && applicationStore && (!applicationStore.state.framework.authenticationState.user || !applicationStore.state.framework.authenticationState.user.isValid)) { history.replace(`/login?returnTo=${action.pathname}`); - } else { + return next(logoutUser()) as any; + + }else if (action.pathname.startsWith("/login") && applicationStore && (applicationStore.state.framework.authenticationState.user && applicationStore.state.framework.authenticationState.user.isValid)) { + history.replace(`/`); + } + else { return next(action); } } else { -- cgit 1.2.3-korg