diff --git a/webapp/packages/core-administration/src/AdministrationScreen/ConfigurationWizard/Pages/ServerConfiguration/ServerConfigurationService.ts b/webapp/packages/core-administration/src/AdministrationScreen/ConfigurationWizard/Pages/ServerConfiguration/ServerConfigurationService.ts index 83858780cd..fdcb554bae 100644 --- a/webapp/packages/core-administration/src/AdministrationScreen/ConfigurationWizard/Pages/ServerConfiguration/ServerConfigurationService.ts +++ b/webapp/packages/core-administration/src/AdministrationScreen/ConfigurationWizard/Pages/ServerConfiguration/ServerConfigurationService.ts @@ -91,7 +91,7 @@ export class ServerConfigurationService { try { await this.graphQLService.gql.setDefaultNavigatorSettings({ settings: this.state.navigatorConfig }); await this.graphQLService.gql.configureServer({ configuration: this.state.serverConfig }); - this.usersResource.refreshAll(); + this.usersResource.refreshAllLazy(); } catch (exception) { this.notificationService.logException(exception, 'Can\'t save server configuration'); diff --git a/webapp/packages/core-authentication/src/UsersResource.ts b/webapp/packages/core-authentication/src/UsersResource.ts index 7d2c412b25..6e2a34c652 100644 --- a/webapp/packages/core-authentication/src/UsersResource.ts +++ b/webapp/packages/core-authentication/src/UsersResource.ts @@ -175,6 +175,11 @@ export class UsersResource extends CachedMapResource { return this.data; } + refreshAllLazy() { + this.markOutdated('all'); + this.metadata.set('all', false); + } + protected async loader(key: ResourceKey): Promise> { const userId = key === 'all' ? undefined : key as string; diff --git a/webapp/packages/plugin-authentication/src/AuthMenuService.ts b/webapp/packages/plugin-authentication/src/AuthMenuService.ts index e8b89bc674..a75a4165a0 100644 --- a/webapp/packages/plugin-authentication/src/AuthMenuService.ts +++ b/webapp/packages/plugin-authentication/src/AuthMenuService.ts @@ -13,7 +13,6 @@ import { injectable, Bootstrap } from '@cloudbeaver/core-di'; import { NotificationService } from '@cloudbeaver/core-events'; import { ServerService } from '@cloudbeaver/core-root'; -import { AuthenticationService } from './AuthenticationService'; import { AuthDialogService } from './Dialog/AuthDialogService'; import { UserInfo } from './UserInfo'; @@ -24,7 +23,6 @@ export class AuthMenuService extends Bootstrap { private authDialogService: AuthDialogService, private authInfoService: AuthInfoService, private settingsMenuService: SettingsMenuService, - private authenticationService: AuthenticationService, private notificationService: NotificationService, private topNavService: TopNavService, private administrationTopAppBarService: AdministrationTopAppBarService, @@ -64,7 +62,6 @@ export class AuthMenuService extends Bootstrap { private async logout() { try { await this.authInfoService.logout(); - await this.authenticationService.auth(); } catch (exception) { this.notificationService.logException(exception, 'Can\'t logout'); } diff --git a/webapp/packages/plugin-authentication/src/AuthenticationService.ts b/webapp/packages/plugin-authentication/src/AuthenticationService.ts index 20c183c9e7..8564fcd4b3 100644 --- a/webapp/packages/plugin-authentication/src/AuthenticationService.ts +++ b/webapp/packages/plugin-authentication/src/AuthenticationService.ts @@ -8,14 +8,16 @@ import { AuthInfoService } from '@cloudbeaver/core-authentication'; import { injectable, Bootstrap } from '@cloudbeaver/core-di'; -import { ServerService } from '@cloudbeaver/core-root'; +import { ServerService, SessionService } from '@cloudbeaver/core-root'; import { AuthDialogService } from './Dialog/AuthDialogService'; @injectable() export class AuthenticationService extends Bootstrap { + private authenticating = false; constructor( private serverService: ServerService, + private sessionService: SessionService, private authDialogService: AuthDialogService, private authInfoService: AuthInfoService, ) { @@ -23,29 +25,37 @@ export class AuthenticationService extends Bootstrap { } async auth() { - const config = await this.serverService.config.load(null); - if (!config) { - throw new Error('Can\'t configure Authentication'); - } - - if (!config.authenticationEnabled) { + if (this.authenticating) { return; } + this.authenticating = true; + try { + const config = await this.serverService.config.load(null); + if (!config) { + throw new Error('Can\'t configure Authentication'); + } - const userInfo = await this.authInfoService.updateAuthInfo(); - if (userInfo) { - return; - } + if (!config.authenticationEnabled) { + return; + } - if (!config.anonymousAccessEnabled) { - await this.authDialogService.showLoginForm(true); + const userInfo = await this.authInfoService.updateAuthInfo(); + if (userInfo) { + return; + } + + if (!config.anonymousAccessEnabled) { + await this.authDialogService.showLoginForm(true); + } + } finally { + this.authenticating = false; } } - register(): void | Promise { } - - load() { - // we do not await it because to unblock app loading - this.auth(); + register(): void | Promise { + this.serverService.config.onDataUpdate.subscribe(this.auth.bind(this)); + this.sessionService.session.onDataUpdate.subscribe(this.auth.bind(this)); } + + load() { } }