From fce5ee6aed6316230b1824111391b0c2865c57cc Mon Sep 17 00:00:00 2001 From: Eric BREHAULT Date: Fri, 15 Sep 2023 16:06:53 +0200 Subject: [PATCH] Ericbrehault/sc 7187/desktop logs out after 5 minutes (#998) * refresh does not need auth token anymore * restore 6 hours delay to refresh * release desktop * do not logout on redirect, as it burns the refresh token * fix test * /refresh needs auth token if the delay is 6 hours (temporary) --- apps/dashboard/src/app/redirect/redirect.component.ts | 3 --- apps/desktop/src/app/app.component.ts | 2 +- libs/sdk-core/src/lib/auth/auth.ts | 5 ++++- package.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/dashboard/src/app/redirect/redirect.component.ts b/apps/dashboard/src/app/redirect/redirect.component.ts index 4e7684053..1587852ca 100644 --- a/apps/dashboard/src/app/redirect/redirect.component.ts +++ b/apps/dashboard/src/app/redirect/redirect.component.ts @@ -43,9 +43,6 @@ export class RedirectComponent { } redirectUrl += redirectUrl.includes('?') ? '&' : '?'; const tokens = `access_token=${this.sdk.nuclia.auth.getToken()}&refresh_token=${this.sdk.nuclia.auth.getRefreshToken()}`; - // logout so the refresh_token we pass to the desktop app is not used in the dashboard - // (a refresh token can only be used one time) - this.sdk.nuclia.auth.logout(); location.href = redirectUrl + tokens; } }); diff --git a/apps/desktop/src/app/app.component.ts b/apps/desktop/src/app/app.component.ts index 7ea9a9d68..f8ec954de 100644 --- a/apps/desktop/src/app/app.component.ts +++ b/apps/desktop/src/app/app.component.ts @@ -33,8 +33,8 @@ export class AppComponent implements OnInit { private paTranslate: PaTranslateService, private ngxTranslate: TranslateService, private user: UserService, - private sdk: SDKService, private router: Router, + private sdk: SDKService, private tracking: STFTrackingService, private modalService: SisModalService, private cdr: ChangeDetectorRef, diff --git a/libs/sdk-core/src/lib/auth/auth.ts b/libs/sdk-core/src/lib/auth/auth.ts index dab1b56fb..0b2300107 100644 --- a/libs/sdk-core/src/lib/auth/auth.ts +++ b/libs/sdk-core/src/lib/auth/auth.ts @@ -8,7 +8,10 @@ import type { AuthTokens, NucliaDBRole } from './auth.models'; const LOCALSTORAGE_AUTH_KEY = 'JWT_KEY'; const LOCALSTORAGE_REFRESH_KEY = 'JWT_REFRESH_KEY'; -const REFRESH_DELAY = 5 * 60 * 1000; // 5 min +// Restore the 6 hours delay as 5 minutes is too painful for the desktop +// (temporary until we have the Deno agent) +const REFRESH_DELAY = 6 * 60 * 60 * 1000; // 6 hours +// const REFRESH_DELAY = 5 * 60 * 1000; // 5 min export class Authentication implements IAuthentication { private nuclia: INuclia; diff --git a/package.json b/package.json index 770ed1b11..ebec6eab9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nuclia", - "version": "2.6.15", + "version": "2.6.16", "license": "MIT", "author": "Nuclia.cloud", "description": "Nuclia frontend apps and libs",