Skip to content

Commit

Permalink
24.04.16: userinfo logout if session expires in less than hour [WTEL-…
Browse files Browse the repository at this point in the history
…4374]
  • Loading branch information
dlohvinov committed Mar 22, 2024
1 parent d409aee commit 41f6f3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webitel/ui-sdk",
"version": "24.4.15",
"version": "24.4.16",
"private": false,
"scripts": {
"dev": "vite",
Expand Down
14 changes: 9 additions & 5 deletions src/modules/Userinfo/store/UserinfoStoreModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,16 @@ export default class UserinfoStoreModule extends BaseStoreModule {
userinfo = userinfoGenerator(instance);

await context.dispatch('BEFORE_OPEN_SESSION_HOOK');
// !!! it should be checked in router.js beforeEach hook
// if (!localStorage.getItem('access-token')) {
// context.dispatch('REDIRECT_TO_AUTH');
// throw new Error('No access-token in localStorage');
// }

const HOUR_LENGTH = 60 * 60 * 1000;

const session = await userinfo.getSession();

if ((session.expiresAt - Date.now() < HOUR_LENGTH)) {
await context.dispatch('LOGOUT');
throw new Error(`Session expires soon ${session.expiresAt}`);
}

await context.dispatch('SET_SESSION', session);
const access = await userinfo.getApplicationsAccess();
await context.dispatch('SET_APPLICATIONS_ACCESS', new ApplicationsAccess({ access }).getAccess());

Check notice on line 108 in src/modules/Userinfo/store/UserinfoStoreModule.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Signature mismatch

Argument type { access: any } is not assignable to parameter type { access: any, value: boolean } Type boolean is not assignable to type undefined
Expand Down

0 comments on commit 41f6f3f

Please sign in to comment.