diff --git a/webapp/packages/core-authentication/src/AppAuthService.ts b/webapp/packages/core-authentication/src/AppAuthService.ts index 36b33f4917..7090a62385 100644 --- a/webapp/packages/core-authentication/src/AppAuthService.ts +++ b/webapp/packages/core-authentication/src/AppAuthService.ts @@ -16,9 +16,7 @@ import { UserInfoResource } from './UserInfoResource.js'; @injectable() export class AppAuthService extends Bootstrap { get authenticated(): boolean { - const user = this.userInfoResource.data; - - return this.serverConfigResource.anonymousAccessEnabled || this.serverConfigResource.configurationMode || user !== null; + return this.serverConfigResource.configurationMode || this.userInfoResource.hasAccess; } get loaders(): ILoadableState[] { @@ -56,9 +54,9 @@ export class AppAuthService extends Bootstrap { throw new Error("Can't configure Authentication"); } - const user = await this.userInfoResource.load(); + await this.userInfoResource.load(); - return !this.serverConfigResource.configurationMode && !this.serverConfigResource.anonymousAccessEnabled && user === null; + return !this.serverConfigResource.configurationMode && !this.userInfoResource.hasAccess; } async authUser(): Promise { diff --git a/webapp/packages/core-authentication/src/UserInfoResource.ts b/webapp/packages/core-authentication/src/UserInfoResource.ts index 4e3b352a87..05e3531fd4 100644 --- a/webapp/packages/core-authentication/src/UserInfoResource.ts +++ b/webapp/packages/core-authentication/src/UserInfoResource.ts @@ -56,7 +56,15 @@ export class UserInfoResource extends CachedDataResource { @@ -94,13 +94,13 @@ export class UserSettingsService extends SettingsSource { private refreshConfig() { this.update(() => { - if (!this.userInfoResource.isAuthenticated()) { + if (!this.userInfoResource.isAuthenticated) { this.clear(); this.lastConfig = null; return; } - if (this.userInfoResource.data.configurationParameters !== this.lastConfig) { + if (this.userInfoResource.isData() && this.userInfoResource.data.configurationParameters !== this.lastConfig) { this.clear(); this.localSettings.clear(); this.lastConfig = this.userInfoResource.data.configurationParameters; @@ -121,7 +121,7 @@ export class UserSettingsService extends SettingsSource { } private getSource() { - if (this.userInfoResource.isAuthenticated()) { + if (this.userInfoResource.isAuthenticated) { return this.settings; } diff --git a/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts b/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts index 17947f7e31..f87351ef73 100644 --- a/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts +++ b/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts @@ -126,7 +126,7 @@ export class ConnectionFoldersBootstrap extends Bootstrap { isActionApplicable: (context, action) => { const tree = context.get(DATA_CONTEXT_ELEMENTS_TREE)!; - if (action !== ACTION_NEW_FOLDER || !this.userInfoResource.data || tree.baseRoot !== ROOT_NODE_PATH) { + if (action !== ACTION_NEW_FOLDER || !this.userInfoResource.isAuthenticated || tree.baseRoot !== ROOT_NODE_PATH) { return false; } diff --git a/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts b/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts index 28b52abf78..ca6492ef29 100644 --- a/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts +++ b/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts @@ -60,7 +60,7 @@ export class PublicConnectionFormService { executorHandlerFilter( () => !!this.formState && this.optionsPanelService.isOpen(formGetter), async (event, context) => { - if (event === 'before' && this.userInfoResource.data === null) { + if (event === 'before' && !this.userInfoResource.isData()) { const confirmed = await this.showUnsavedChangesDialog(); if (!confirmed) { ExecutorInterrupter.interrupt(context); diff --git a/webapp/packages/plugin-navigation-tree-rm/src/NavNodes/ResourceFoldersBootstrap.ts b/webapp/packages/plugin-navigation-tree-rm/src/NavNodes/ResourceFoldersBootstrap.ts index f285c2dac5..3fb8572474 100644 --- a/webapp/packages/plugin-navigation-tree-rm/src/NavNodes/ResourceFoldersBootstrap.ts +++ b/webapp/packages/plugin-navigation-tree-rm/src/NavNodes/ResourceFoldersBootstrap.ts @@ -89,7 +89,7 @@ export class ResourceFoldersBootstrap extends Bootstrap { isActionApplicable: context => { const tree = context.get(DATA_CONTEXT_ELEMENTS_TREE); - if (!tree?.baseRoot.startsWith(RESOURCES_NODE_PATH) || !this.userInfoResource.data) { + if (!tree?.baseRoot.startsWith(RESOURCES_NODE_PATH) || !this.userInfoResource.isAuthenticated) { return false; } diff --git a/webapp/packages/plugin-resource-manager/src/ResourceManagerService.ts b/webapp/packages/plugin-resource-manager/src/ResourceManagerService.ts index 6e1fc54ef1..22af72f735 100644 --- a/webapp/packages/plugin-resource-manager/src/ResourceManagerService.ts +++ b/webapp/packages/plugin-resource-manager/src/ResourceManagerService.ts @@ -7,7 +7,7 @@ */ import { computed, makeObservable } from 'mobx'; -import { AuthInfoService } from '@cloudbeaver/core-authentication'; +import { UserInfoResource } from '@cloudbeaver/core-authentication'; import { injectable } from '@cloudbeaver/core-di'; import type { ProjectInfo } from '@cloudbeaver/core-projects'; import { ServerConfigResource } from '@cloudbeaver/core-root'; @@ -15,11 +15,11 @@ import { ServerConfigResource } from '@cloudbeaver/core-root'; @injectable() export class ResourceManagerService { get enabled() { - return !!this.serverConfigResource.data?.resourceManagerEnabled && !!this.authInfoService.userInfo; + return !!this.serverConfigResource.data?.resourceManagerEnabled && this.userInfoResource.isAuthenticated; } constructor( - private readonly authInfoService: AuthInfoService, + private readonly userInfoResource: UserInfoResource, private readonly serverConfigResource: ServerConfigResource, ) { makeObservable(this, { diff --git a/webapp/packages/plugin-session-expiration/src/SessionExpireWarningDialog/SessionExpireWarningDialogBootstrap.ts b/webapp/packages/plugin-session-expiration/src/SessionExpireWarningDialog/SessionExpireWarningDialogBootstrap.ts index 9b89ac637b..db49c48472 100644 --- a/webapp/packages/plugin-session-expiration/src/SessionExpireWarningDialog/SessionExpireWarningDialogBootstrap.ts +++ b/webapp/packages/plugin-session-expiration/src/SessionExpireWarningDialog/SessionExpireWarningDialogBootstrap.ts @@ -38,7 +38,7 @@ export class SessionExpireWarningDialogBootstrap extends Bootstrap { } private handleSessionResourceDataUpdate(isValid?: boolean, remainingTime?: number) { - if (!this.serverConfigResource.anonymousAccessEnabled && !this.userInfoResource.data && !this.serverConfigResource.configurationMode) { + if (!this.serverConfigResource.configurationMode && !this.userInfoResource.hasAccess) { return; } diff --git a/webapp/packages/plugin-user-profile/src/UserMenu/UserMenu.tsx b/webapp/packages/plugin-user-profile/src/UserMenu/UserMenu.tsx index 2d8f9a05ee..d5dc2d0bcb 100644 --- a/webapp/packages/plugin-user-profile/src/UserMenu/UserMenu.tsx +++ b/webapp/packages/plugin-user-profile/src/UserMenu/UserMenu.tsx @@ -27,7 +27,7 @@ export const UserMenu = observer(function UserMenu() { context.set(DATA_CONTEXT_USER, userInfoResource.data, id); }); - if (!userInfoResource.isAuthenticated()) { + if (!userInfoResource.isData() || !userInfoResource.isAuthenticated) { return null; } diff --git a/webapp/packages/plugin-user-profile/src/UserProfileOptionsPanelService.ts b/webapp/packages/plugin-user-profile/src/UserProfileOptionsPanelService.ts index 439ab5d974..0e0f820161 100644 --- a/webapp/packages/plugin-user-profile/src/UserProfileOptionsPanelService.ts +++ b/webapp/packages/plugin-user-profile/src/UserProfileOptionsPanelService.ts @@ -82,7 +82,7 @@ export class UserProfileOptionsPanelService { return; } - if (this.userInfoResource.data === null) { + if (!this.userInfoResource.isData()) { this.close(true); } }