diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebSession.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebSession.java index b428edc12f..c5bba65cbd 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebSession.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebSession.java @@ -125,13 +125,13 @@ public class WebSession extends BaseWebSession private final Map sessionHandlers; public WebSession( - @NotNull HttpSession httpSession, + @NotNull HttpServletRequest request, @NotNull WebAuthApplication application, @NotNull Map sessionHandlers ) throws DBException { - super(httpSession.getId(), application); + super(request.getSession().getId(), application); this.lastAccessTime = this.createTime; - setLocale(CommonUtils.toString(httpSession.getAttribute(ATTR_LOCALE), this.locale)); + setLocale(CommonUtils.toString(request.getSession().getAttribute(ATTR_LOCALE), this.locale)); this.sessionHandlers = sessionHandlers; //force authorization of anonymous session to avoid access error, //because before authorization could be called by any request, @@ -139,6 +139,7 @@ public WebSession( //and the order of requests is not guaranteed. //look at CB-4747 refreshSessionAuth(); + updateSessionParameters(request); } @Nullable @@ -525,17 +526,10 @@ public List getSessionMessages() { } } - public synchronized void updateInfo( - HttpServletRequest request, - HttpServletResponse response - ) throws DBWebException { + public synchronized void updateInfo(boolean isOldHttpSessionUsed) { log.debug("Update session lifetime " + getSessionId() + " for user " + getUserId()); touchSession(); - HttpSession httpSession = request.getSession(); - this.lastRemoteAddr = request.getRemoteAddr(); - this.lastRemoteUserAgent = request.getHeader("User-Agent"); - this.cacheExpired = false; - if (!httpSession.isNew()) { + if (isOldHttpSessionUsed) { try { // Persist session if (!isAuthorizedInSecurityManager()) { @@ -555,6 +549,12 @@ public synchronized void updateInfo( } } + public synchronized void updateSessionParameters(HttpServletRequest request) { + this.lastRemoteAddr = request.getRemoteAddr(); + this.lastRemoteUserAgent = request.getHeader("User-Agent"); + this.cacheExpired = false; + } + @Association public List getConnections() { synchronized (connections) { diff --git a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls index b393c48824..faf8c4a166 100644 --- a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls +++ b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls @@ -566,9 +566,9 @@ extend type Mutation { closeSession: Boolean # Refreshes session on server and returns its state - touchSession: Boolean @deprecated(reason: "use updateSession instead") + touchSession: Boolean @deprecated(reason: "use events to update session") # Refreshes session on server and returns session state - updateSession: SessionInfo! @since(version: "24.0.0") + updateSession: SessionInfo! @since(version: "24.0.0") @deprecated(reason: "use events to update session") # Refresh session connection list refreshSessionConnections: Boolean diff --git a/server/bundles/io.cloudbeaver.server/schema/service.events.graphqls b/server/bundles/io.cloudbeaver.server/schema/service.events.graphqls index 515b89b30d..3c506edd11 100644 --- a/server/bundles/io.cloudbeaver.server/schema/service.events.graphqls +++ b/server/bundles/io.cloudbeaver.server/schema/service.events.graphqls @@ -37,7 +37,8 @@ enum CBServerEventId { enum CBClientEventId { cb_client_topic_subscribe, cb_client_topic_unsubscribe, - cb_client_projects_active + cb_client_projects_active, + cb_client_session_ping } # Client subscribes on topic to receive only related events @@ -114,8 +115,12 @@ type WSSocketConnectedEvent implements CBServerEvent { type WSSessionStateEvent implements CBServerEvent { id: CBServerEventId! topicId: CBEventTopic + lastAccessTime: Int! remainingTime: Int! isValid: Boolean + isCacheExpired: Boolean + locale: String! + actionParameters: Object } # Session expired event diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/websockets/CBEventsWebSocket.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/websockets/CBEventsWebSocket.java index ddf70ca3cb..697011c5d4 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/websockets/CBEventsWebSocket.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/websockets/CBEventsWebSocket.java @@ -18,6 +18,7 @@ import io.cloudbeaver.DBWebException; import io.cloudbeaver.model.session.BaseWebSession; +import io.cloudbeaver.model.session.WebSession; import io.cloudbeaver.websocket.CBWebSessionEventHandler; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WriteCallback; @@ -76,6 +77,12 @@ public void onWebSocketText(String message) { this.webSession.getEventsFilter().setSubscribedProjects(projectEvent.getProjectIds()); break; } + case SESSION_PING: { + if (webSession instanceof WebSession session) { + session.updateInfo(true); + } + break; + } default: var e = new DBWebException("Unknown websocket client event: " + clientEvent.getId()); log.error(e.getMessage(), e); diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/websockets/CBJettyWebSocketManager.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/websockets/CBJettyWebSocketManager.java index 28295b75eb..02c730dd10 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/websockets/CBJettyWebSocketManager.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/websockets/CBJettyWebSocketManager.java @@ -29,6 +29,7 @@ import org.jkiss.dbeaver.DBException; import org.jkiss.dbeaver.Log; import org.jkiss.dbeaver.model.security.exception.SMAccessTokenExpiredException; +import org.jkiss.dbeaver.runtime.DBWorkbench; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; @@ -54,6 +55,7 @@ public Object createWebSocket(@NotNull JettyServerUpgradeRequest request, JettyS var httpRequest = request.getHttpServletRequest(); var webSession = webSessionManager.getOrRestoreSession(httpRequest); if (webSession != null) { + webSession.updateSessionParameters(httpRequest); // web client session return createNewEventsWebSocket(webSession); } diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/DBWServiceCore.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/DBWServiceCore.java index e684f44669..c8b8eb1b39 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/DBWServiceCore.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/DBWServiceCore.java @@ -94,6 +94,7 @@ WebSession openSession( @WebAction(authRequired = false) boolean touchSession(@NotNull HttpServletRequest request, @NotNull HttpServletResponse servletResponse) throws DBWebException; + @Deprecated @WebAction(authRequired = false) WebSession updateSession(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws DBWebException; diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/impl/WebServiceCore.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/impl/WebServiceCore.java index 66e3eb2952..b7ecbe852f 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/impl/WebServiceCore.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/impl/WebServiceCore.java @@ -282,11 +282,13 @@ public boolean closeSession(HttpServletRequest request) throws DBWebException { } @Override + @Deprecated public boolean touchSession(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws DBWebException { return CBPlatform.getInstance().getSessionManager().touchSession(request, response); } @Override + @Deprecated public WebSession updateSession(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws DBWebException { WebSessionManager sessionManager = CBPlatform.getInstance().getSessionManager(); diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/session/WebSessionManager.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/session/WebSessionManager.java index 6704c92ffd..d77bf2a154 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/session/WebSessionManager.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/session/WebSessionManager.java @@ -79,10 +79,12 @@ protected CBApplication getApplication() { return application; } + @Deprecated public boolean touchSession(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws DBWebException { WebSession webSession = getWebSession(request, response, false); - webSession.updateInfo(request, response); + webSession.updateSessionParameters(request); + webSession.updateInfo(!request.getSession().isNew()); return true; } @@ -105,14 +107,14 @@ public WebSession getWebSession( var baseWebSession = sessionMap.get(sessionId); if (baseWebSession == null && CBApplication.getInstance().isConfigurationMode()) { try { - webSession = createWebSessionImpl(httpSession); + webSession = createWebSessionImpl(request); } catch (DBException e) { throw new DBWebException("Failed to create web session", e); } sessionMap.put(sessionId, webSession); } else if (baseWebSession == null) { try { - webSession = createWebSessionImpl(httpSession); + webSession = createWebSessionImpl(request); } catch (DBException e) { throw new DBWebException("Failed to create web session", e); } @@ -174,7 +176,7 @@ public WebSession getOrRestoreSession(@NotNull HttpServletRequest request) { return null; } - webSession = createWebSessionImpl(httpSession); + webSession = createWebSessionImpl(request); restorePreviousUserSession(webSession, oldAuthInfo); sessionMap.put(sessionId, webSession); @@ -208,8 +210,8 @@ private void restorePreviousUserSession( } @NotNull - protected WebSession createWebSessionImpl(@NotNull HttpSession httpSession) throws DBException { - return new WebSession(httpSession, application, getSessionHandlers()); + protected WebSession createWebSessionImpl(@NotNull HttpServletRequest request) throws DBException { + return new WebSession(request, application, getSessionHandlers()); } @NotNull @@ -330,7 +332,13 @@ public void sendSessionsStates() { }) .forEach(session -> { try { - session.addSessionEvent(new WSSessionStateEvent(session.getRemainingTime(), session.isValid())); + session.addSessionEvent(new WSSessionStateEvent( + session.getLastAccessTimeMillis(), + session.getRemainingTime(), + session.isValid(), + ((WebSession) session).isCacheExpired(), + ((WebSession) session).getLocale(), + ((WebSession) session).getActionParameters())); } catch (Exception e) { log.error("Failed to refresh session state: " + session.getSessionId(), e); } diff --git a/webapp/packages/core-authentication/src/AuthConfigurationsResource.ts b/webapp/packages/core-authentication/src/AuthConfigurationsResource.ts index be4acb05d7..14960db42b 100644 --- a/webapp/packages/core-authentication/src/AuthConfigurationsResource.ts +++ b/webapp/packages/core-authentication/src/AuthConfigurationsResource.ts @@ -30,7 +30,10 @@ type NewConfiguration = AuthConfiguration & { [NEW_CONFIGURATION_SYMBOL]: boolea @injectable() export class AuthConfigurationsResource extends CachedMapResource { - constructor(private readonly graphQLService: GraphQLService, permissionsResource: SessionPermissionsResource) { + constructor( + private readonly graphQLService: GraphQLService, + permissionsResource: SessionPermissionsResource, + ) { super(() => new Map(), []); permissionsResource.require(this, EAdminPermission.admin).outdateResource(this); @@ -51,6 +54,7 @@ export class AuthConfigurationsResource extends CachedMapResource { - return await this.performUpdate(getContextBaseId(key, ''), [], async () => { + const contextKey = getContextBaseId(key, ''); + return await this.performUpdate(contextKey, [], async () => { const { context } = await this.graphQLService.sdk.executionContextCreate({ ...key, defaultCatalog, @@ -85,7 +86,10 @@ export class ConnectionExecutionContextResource extends CachedMapResource { diff --git a/webapp/packages/core-connections/src/ConnectionFolderResource.ts b/webapp/packages/core-connections/src/ConnectionFolderResource.ts index 5b25873085..63bbab8571 100644 --- a/webapp/packages/core-connections/src/ConnectionFolderResource.ts +++ b/webapp/packages/core-connections/src/ConnectionFolderResource.ts @@ -37,7 +37,11 @@ export const ConnectionFolderProjectKey = resourceKeyAliasFactory('@connection-f @injectable() export class ConnectionFolderResource extends CachedMapResource { - constructor(private readonly graphQLService: GraphQLService, sessionDataResource: SessionDataResource, appAuthService: AppAuthService) { + constructor( + private readonly graphQLService: GraphQLService, + sessionDataResource: SessionDataResource, + appAuthService: AppAuthService, + ) { super(); appAuthService.requireAuthentication(this); @@ -70,6 +74,7 @@ export class ConnectionFolderResource extends CachedMapResource { diff --git a/webapp/packages/core-navigation-tree/src/NodesManager/NavTreeResource.ts b/webapp/packages/core-navigation-tree/src/NodesManager/NavTreeResource.ts index dfad4051f6..566b9f30f0 100644 --- a/webapp/packages/core-navigation-tree/src/NodesManager/NavTreeResource.ts +++ b/webapp/packages/core-navigation-tree/src/NodesManager/NavTreeResource.ts @@ -193,6 +193,7 @@ export class NavTreeResource extends CachedMapResource { const deletedNodes: string[] = []; @@ -223,8 +224,9 @@ export class NavTreeResource extends CachedMapResource, target: string): Promise { const parents = Array.from(new Set(ResourceKeyUtils.mapArray(key, key => this.navNodeInfoResource.get(key)?.parentId).filter(isDefined))); + const parentsKey = resourceKeyList(parents); - await this.performUpdate(resourceKeyList(parents), [], async () => { + await this.performUpdate(parentsKey, [], async () => { this.markLoading(target, true); try { @@ -235,6 +237,7 @@ export class NavTreeResource extends CachedMapResource 0) { diff --git a/webapp/packages/core-resource/src/Resource/CachedResource.ts b/webapp/packages/core-resource/src/Resource/CachedResource.ts index 25e2e720b0..6dbf5c6a95 100644 --- a/webapp/packages/core-resource/src/Resource/CachedResource.ts +++ b/webapp/packages/core-resource/src/Resource/CachedResource.ts @@ -110,13 +110,16 @@ export abstract class CachedResource< clear: action, }); - setInterval(() => { - // mark resource outdate when it's not used - if (!this.useTracker.isResourceInUse && !this.isOutdated()) { - this.logger.log('not in use'); - this.markOutdated(); - } - }, 5 * 60 * 1000); + setInterval( + () => { + // mark resource outdate when it's not used + if (!this.useTracker.isResourceInUse && !this.isOutdated()) { + this.logger.log('not in use'); + this.markOutdated(); + } + }, + 5 * 60 * 1000, + ); } /** @@ -517,6 +520,11 @@ export abstract class CachedResource< this.setData(this.defaultValue()); } + /** + * Sets data to the resource. Forbidden to use outside of the loader or performUpdate functions! + * @param data - new data + * @returns {void} + */ protected setData(data: TData): void { this.data = data; } @@ -601,6 +609,7 @@ export abstract class CachedResource< * Implements same behavior as {@link CachedResource.load} and {@link CachedResource.refresh} for custom loaders. * Resource will be marked as loading and will be marked as loaded after loader is finished. * Exceptions will be handled and stored in metadata. + * Tip: use onDataOutdated executor with this function where it is needed. * @param key - Resource key * @param include - Includes * @param update - Update function @@ -651,7 +660,6 @@ export abstract class CachedResource< { success: () => { if (loaded) { - this.onDataOutdated.execute(key); // TODO: probably need to remove, we need to notify any related resources that subscribed to .onOutdate, to recursively outdate them this.dataUpdate(key); } }, diff --git a/webapp/packages/core-root/src/ServerConfigResource.ts b/webapp/packages/core-root/src/ServerConfigResource.ts index c4f1dd2fc3..840a5781d6 100644 --- a/webapp/packages/core-root/src/ServerConfigResource.ts +++ b/webapp/packages/core-root/src/ServerConfigResource.ts @@ -232,6 +232,7 @@ export class ServerConfigResource extends CachedDataResource { await this.graphQLService.sdk.updateProductConfiguration({ configuration }); this.setData(await this.loader()); + this.onDataOutdated.execute(); }); } @@ -256,6 +257,8 @@ export class ServerConfigResource extends CachedDataResource !this.isNavigatorSettingsChanged() && (!this.isChanged() || skipConfigUpdate), ); @@ -271,6 +274,7 @@ export class ServerConfigResource extends CachedDataResource !this.isChanged() && !onlyRestart, ); diff --git a/webapp/packages/core-root/src/SessionActivityService.ts b/webapp/packages/core-root/src/SessionActivityService.ts index cd6a5dc144..ab24782851 100644 --- a/webapp/packages/core-root/src/SessionActivityService.ts +++ b/webapp/packages/core-root/src/SessionActivityService.ts @@ -16,22 +16,21 @@ export const SESSION_TOUCH_TIME_PERIOD = 1000 * 60; export class SessionActivityService extends Dependency { private touchSessionTimer: ReturnType | null = null; - constructor(private readonly clientActivityService: ClientActivityService, private readonly sessionResource: SessionResource) { + constructor( + private readonly clientActivityService: ClientActivityService, + private readonly sessionResource: SessionResource, + ) { super(); this.notifyClientActivity = this.notifyClientActivity.bind(this); this.clientActivityService.onActiveStateChange.addHandler(this.notifyClientActivity); } - private async notifyClientActivity() { + private notifyClientActivity() { if (this.touchSessionTimer || !this.clientActivityService.isActive) { return; } - try { - await this.sessionResource.updateSession(); - } catch (e) { - console.error('Session update error', e); - } + this.sessionResource.pingSession(); this.touchSessionTimer = setTimeout(() => { if (this.touchSessionTimer) { diff --git a/webapp/packages/core-root/src/SessionInfoEventHandler.ts b/webapp/packages/core-root/src/SessionInfoEventHandler.ts index b376a326f7..fe80326f87 100644 --- a/webapp/packages/core-root/src/SessionInfoEventHandler.ts +++ b/webapp/packages/core-root/src/SessionInfoEventHandler.ts @@ -6,10 +6,10 @@ * you may not use this file except in compliance with the License. */ import { injectable } from '@cloudbeaver/core-di'; -import type { WsSessionStateEvent as ISessionStateEvent } from '@cloudbeaver/core-sdk'; +import { type CbClientEvent, CbEventTopic, type WsSessionStateEvent as ISessionStateEvent } from '@cloudbeaver/core-sdk'; import { TopicEventHandler } from './ServerEventEmitter/TopicEventHandler'; -import { ISessionEvent, SessionEventId, SessionEventSource, SessionEventTopic } from './SessionEventSource'; +import { ClientEventId, ISessionEvent, SessionEventId, SessionEventSource, SessionEventTopic } from './SessionEventSource'; export { type ISessionStateEvent }; @@ -19,6 +19,10 @@ export class SessionInfoEventHandler extends TopicEventHandler({ id: ClientEventId.CbClientSessionPing, topicId: CbEventTopic.CbSession }); + } + map(event: any): ISessionStateEvent { return event; } diff --git a/webapp/packages/core-root/src/SessionResource.ts b/webapp/packages/core-root/src/SessionResource.ts index b9479333a5..19af9c4b3a 100644 --- a/webapp/packages/core-root/src/SessionResource.ts +++ b/webapp/packages/core-root/src/SessionResource.ts @@ -6,13 +6,12 @@ * you may not use this file except in compliance with the License. */ import { injectable } from '@cloudbeaver/core-di'; -import { ISyncExecutor, SyncExecutor } from '@cloudbeaver/core-executor'; import { CachedDataResource } from '@cloudbeaver/core-resource'; import { GraphQLService, SessionStateFragment } from '@cloudbeaver/core-sdk'; import { ServerConfigResource } from './ServerConfigResource'; import { ServerEventId } from './SessionEventSource'; -import { SessionInfoEventHandler } from './SessionInfoEventHandler'; +import { type ISessionStateEvent, SessionInfoEventHandler } from './SessionInfoEventHandler'; export type SessionState = SessionStateFragment; export interface ISessionAction { @@ -20,38 +19,21 @@ export interface ISessionAction { [key: string]: any; } -interface SessionStateData { - isValid?: boolean; - remainingTime: number; -} - @injectable() export class SessionResource extends CachedDataResource { private action: ISessionAction | null; private defaultLocale: string | undefined; - readonly onStatusUpdate: ISyncExecutor; constructor( private readonly graphQLService: GraphQLService, - sessionInfoEventHandler: SessionInfoEventHandler, + private readonly sessionInfoEventHandler: SessionInfoEventHandler, serverConfigResource: ServerConfigResource, ) { super(() => null); - this.onStatusUpdate = new SyncExecutor(); - sessionInfoEventHandler.onEvent( - ServerEventId.CbSessionState, - event => { - if (this.data) { - this.data.valid = event.isValid ?? this.data.valid; - this.data.remainingTime = event.remainingTime; - // TODO: probably we want to call here this.dataUpdate - } - this.onStatusUpdate.execute(event); - }, - undefined, - this, - ); + this.handleSessionStateEvent = this.handleSessionStateEvent.bind(this); + + sessionInfoEventHandler.onEvent(ServerEventId.CbSessionState, this.handleSessionStateEvent, undefined, this); this.action = null; this.sync( @@ -73,6 +55,26 @@ export class SessionResource extends CachedDataResource { this.defaultLocale = defaultLocale; } + private handleSessionStateEvent(event: ISessionStateEvent) { + this.performUpdate(undefined, [], async () => { + if (!this.data) { + return; + } + + const sessionState: SessionState = { + ...this.data, + valid: event?.isValid ?? this.data.valid, + remainingTime: event.remainingTime, + actionParameters: event.actionParameters, + cacheExpired: event?.isCacheExpired ?? this.data.cacheExpired, + lastAccessTime: String(event.lastAccessTime), + locale: event.locale, + }; + + this.setData(sessionState); + }); + } + async changeLanguage(locale: string): Promise { if (this.data?.locale === locale) { return; @@ -93,16 +95,12 @@ export class SessionResource extends CachedDataResource { return session; } - async updateSession() { + pingSession() { if (!this.data?.valid) { return; } - const { updateSession } = await this.graphQLService.sdk.updateSession(); - - this.setData(updateSession); - - return updateSession; + this.sessionInfoEventHandler.pingSession(); } protected setData(data: SessionState | null) { diff --git a/webapp/packages/plugin-session-expiration/src/SessionExpireWarningDialog/SessionExpireWarningDialogBootstrap.ts b/webapp/packages/plugin-session-expiration/src/SessionExpireWarningDialog/SessionExpireWarningDialogBootstrap.ts index 7567820fb4..06ec2a584a 100644 --- a/webapp/packages/plugin-session-expiration/src/SessionExpireWarningDialog/SessionExpireWarningDialogBootstrap.ts +++ b/webapp/packages/plugin-session-expiration/src/SessionExpireWarningDialog/SessionExpireWarningDialogBootstrap.ts @@ -9,7 +9,6 @@ import { UserInfoResource } from '@cloudbeaver/core-authentication'; import { importLazyComponent } from '@cloudbeaver/core-blocks'; import { Bootstrap, injectable } from '@cloudbeaver/core-di'; import { CommonDialogService, DialogueStateResult } from '@cloudbeaver/core-dialogs'; -import { NotificationService } from '@cloudbeaver/core-events'; import { ServerConfigResource, SESSION_EXPIRE_MIN_TIME, SessionExpireService, SessionResource } from '@cloudbeaver/core-root'; import { GraphQLService } from '@cloudbeaver/core-sdk'; @@ -24,7 +23,6 @@ export class SessionExpireWarningDialogBootstrap extends Bootstrap { private readonly sessionResource: SessionResource, private readonly userInfoResource: UserInfoResource, private readonly graphQLService: GraphQLService, - private readonly notificationService: NotificationService, ) { super(); this.dialogInternalPromise = null; @@ -32,14 +30,16 @@ export class SessionExpireWarningDialogBootstrap extends Bootstrap { register(): void { this.sessionExpireService.onSessionExpire.addHandler(this.close.bind(this)); - this.sessionResource.onStatusUpdate.addHandler((data, contexts) => { - this.handleStateChange(data.isValid, data.remainingTime); + this.sessionResource.onDataUpdate.addHandler(() => { + const { valid, remainingTime } = this.sessionResource.data || {}; + + this.handleSessionResourceDataUpdate(valid, remainingTime); }); } load(): void {} - private handleStateChange(isValid?: boolean, remainingTime?: number) { + private handleSessionResourceDataUpdate(isValid?: boolean, remainingTime?: number) { if (!this.serverConfigResource.anonymousAccessEnabled && !this.userInfoResource.data && !this.serverConfigResource.configurationMode) { return; } @@ -74,11 +74,7 @@ export class SessionExpireWarningDialogBootstrap extends Bootstrap { const { sessionState } = await this.graphQLService.sdk.sessionState(); if (sessionState.valid) { - try { - await this.sessionResource.updateSession(); - } catch (e: any) { - this.notificationService.logException(e, 'plugin_session_expiration_session_update_error'); - } + this.sessionResource.pingSession(); } else { this.sessionExpireService.sessionExpired(); } diff --git a/webapp/packages/plugin-session-expiration/src/locales/en.ts b/webapp/packages/plugin-session-expiration/src/locales/en.ts index 8c94cf3aff..d6d1738de6 100644 --- a/webapp/packages/plugin-session-expiration/src/locales/en.ts +++ b/webapp/packages/plugin-session-expiration/src/locales/en.ts @@ -1 +1 @@ -export default [['plugin_session_expiration_session_update_error', 'Session update failed']]; +export default []; diff --git a/webapp/packages/plugin-session-expiration/src/locales/it.ts b/webapp/packages/plugin-session-expiration/src/locales/it.ts index 8c94cf3aff..d6d1738de6 100644 --- a/webapp/packages/plugin-session-expiration/src/locales/it.ts +++ b/webapp/packages/plugin-session-expiration/src/locales/it.ts @@ -1 +1 @@ -export default [['plugin_session_expiration_session_update_error', 'Session update failed']]; +export default []; diff --git a/webapp/packages/plugin-session-expiration/src/locales/ru.ts b/webapp/packages/plugin-session-expiration/src/locales/ru.ts index 4404022cc8..d6d1738de6 100644 --- a/webapp/packages/plugin-session-expiration/src/locales/ru.ts +++ b/webapp/packages/plugin-session-expiration/src/locales/ru.ts @@ -1 +1 @@ -export default [['plugin_session_expiration_session_update_error', 'Не удалось обновить сессию']]; +export default []; diff --git a/webapp/packages/plugin-session-expiration/src/locales/zh.ts b/webapp/packages/plugin-session-expiration/src/locales/zh.ts index 8c94cf3aff..d6d1738de6 100644 --- a/webapp/packages/plugin-session-expiration/src/locales/zh.ts +++ b/webapp/packages/plugin-session-expiration/src/locales/zh.ts @@ -1 +1 @@ -export default [['plugin_session_expiration_session_update_error', 'Session update failed']]; +export default [];