diff options
Diffstat (limited to 'sdnr/wt/odlux/framework/src/handlers/authenticationHandler.ts')
-rw-r--r-- | sdnr/wt/odlux/framework/src/handlers/authenticationHandler.ts | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sdnr/wt/odlux/framework/src/handlers/authenticationHandler.ts b/sdnr/wt/odlux/framework/src/handlers/authenticationHandler.ts index c0f2b4215..82b228dc0 100644 --- a/sdnr/wt/odlux/framework/src/handlers/authenticationHandler.ts +++ b/sdnr/wt/odlux/framework/src/handlers/authenticationHandler.ts @@ -21,6 +21,7 @@ import { UpdateAuthentication } from '../actions/authentication'; import { User } from '../models/authentication'; import { onLogin, onLogout } from '../services/applicationApi'; +import { startWebsocketSession, endWebsocketSession } from '../services/notificationService'; export interface IAuthenticationState { user?: User; @@ -28,6 +29,10 @@ export interface IAuthenticationState { const initialToken = localStorage.getItem("userToken"); +if (initialToken !== null) { + startWebsocketSession(); +} + const authenticationStateInit: IAuthenticationState = { user: initialToken && User.fromString(initialToken) || undefined }; @@ -38,9 +43,11 @@ export const authenticationStateHandler: IActionHandler<IAuthenticationState> = const user = action.bearerToken && new User(action.bearerToken) || undefined; if (user) { localStorage.setItem("userToken", user.toString()); + startWebsocketSession(); onLogin(); } else { localStorage.removeItem("userToken"); + endWebsocketSession(); onLogout(); } |