mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
feat(core-app): CB-2138 add don't poll session if cookies are disabled
This commit is contained in:
+10
-7
@@ -9,7 +9,7 @@
|
||||
import { UserInfoResource } from '@cloudbeaver/core-authentication';
|
||||
import { Bootstrap, injectable } from '@cloudbeaver/core-di';
|
||||
import { CommonDialogService, DialogueStateResult } from '@cloudbeaver/core-dialogs';
|
||||
import { ServerConfigResource, SessionExpireService, SessionResource } from '@cloudbeaver/core-root';
|
||||
import { ServerConfigResource, SessionExpireService, SessionResource, CookiesService } from '@cloudbeaver/core-root';
|
||||
import { getCookies } from '@cloudbeaver/core-utils';
|
||||
|
||||
import { SessionExpireWarningDialog } from '../SessionExpireWarningDialog/SessionExpireWarningDialog';
|
||||
@@ -23,11 +23,12 @@ export class SessionExpireWarningDialogService extends Bootstrap {
|
||||
private dialogInternalPromise: Promise<DialogueStateResult | null> | null;
|
||||
|
||||
constructor(
|
||||
private commonDialogService: CommonDialogService,
|
||||
private sessionExpireService: SessionExpireService,
|
||||
private serverConfigResource: ServerConfigResource,
|
||||
private sessionResource: SessionResource,
|
||||
private userInfoResource: UserInfoResource
|
||||
private readonly commonDialogService: CommonDialogService,
|
||||
private readonly sessionExpireService: SessionExpireService,
|
||||
private readonly serverConfigResource: ServerConfigResource,
|
||||
private readonly sessionResource: SessionResource,
|
||||
private readonly userInfoResource: UserInfoResource,
|
||||
private readonly cookiesService: CookiesService
|
||||
) {
|
||||
super();
|
||||
this.dialogInternalPromise = null;
|
||||
@@ -38,7 +39,9 @@ export class SessionExpireWarningDialogService extends Bootstrap {
|
||||
}
|
||||
|
||||
load(): void {
|
||||
this.startSessionPolling();
|
||||
if (this.cookiesService.cookiesEnabled) {
|
||||
this.startSessionPolling();
|
||||
}
|
||||
}
|
||||
|
||||
private startSessionPolling() {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2022 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { injectable } from '@cloudbeaver/core-di';
|
||||
|
||||
import { CookiesSettingsService } from './CookiesSettingsService';
|
||||
|
||||
@injectable()
|
||||
export class CookiesService {
|
||||
get cookiesEnabled() {
|
||||
return !this.cookiesSettingsService.settings.getValue('disabled');
|
||||
}
|
||||
|
||||
constructor(private readonly cookiesSettingsService: CookiesSettingsService) {}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2022 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { injectable } from '@cloudbeaver/core-di';
|
||||
import { PluginManagerService, PluginSettings } from '@cloudbeaver/core-plugin';
|
||||
|
||||
const defaultSettings = {
|
||||
disabled: false,
|
||||
};
|
||||
|
||||
export type CookiesSettings = typeof defaultSettings;
|
||||
|
||||
@injectable()
|
||||
export class CookiesSettingsService {
|
||||
readonly settings: PluginSettings<CookiesSettings>;
|
||||
|
||||
constructor(private readonly pluginManagerService: PluginManagerService) {
|
||||
this.settings = this.pluginManagerService.getPluginSettings('core.cookies', defaultSettings);
|
||||
}
|
||||
}
|
||||
@@ -15,4 +15,5 @@ export * from './SessionSettingsService';
|
||||
export * from './SessionExpireService';
|
||||
export * from './usePermission';
|
||||
export * from './WindowEventsService';
|
||||
export * from './CookiesService';
|
||||
export { manifest as coreRootManifest } from './manifest';
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
import type { PluginManifest } from '@cloudbeaver/core-di';
|
||||
|
||||
import { CookiesService } from './CookiesService';
|
||||
import { CookiesSettingsService } from './CookiesSettingsService';
|
||||
import { FeaturesResource } from './FeaturesResource';
|
||||
import { NetworkStateService } from './NetworkStateService';
|
||||
import { PermissionsResource } from './PermissionsResource';
|
||||
@@ -44,5 +46,7 @@ export const manifest: PluginManifest = {
|
||||
SessionService,
|
||||
SessionSettingsService,
|
||||
WindowEventsService,
|
||||
CookiesSettingsService,
|
||||
CookiesService,
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user