feat(core): add allowGuestDemoWorkspace flag to force login (#12779)

https://github.com/user-attachments/assets/41a659c9-6def-4492-be8e-5910eb148d6f

This PR enforces login‑first access (#8716) by disabling or enabling the
guest demo workspace via Admin Server Client Page and redirecting
unauthenticated users straight to `/sign‑in`.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a configuration option to control whether guest users can create
demo workspaces.
* Updated server and client interfaces, GraphQL schema, and queries to
support the new guest demo workspace flag.

* **Bug Fixes**
* Improved sign-out behavior to redirect users appropriately based on
guest demo workspace permissions.
* Enhanced navigation flow to handle guest demo workspace access and
user authentication state.

* **Tests**
* Added tests to verify sign-out logic when guest demo workspaces are
enabled or disabled.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: liuyi <forehalo@gmail.com>
Co-authored-by: fengmk2 <fengmk2@gmail.com>
This commit is contained in:
Richard Lora
2025-06-29 10:17:18 -04:00
committed by GitHub
parent a4680d236d
commit 82b3c0d264
25 changed files with 209 additions and 34 deletions
@@ -26,6 +26,7 @@ export const BUILD_IN_SERVERS: (ServerMetadata & { config: ServerConfig })[] =
maxLength: 32,
},
},
allowGuestDemoWorkspace: true,
},
},
]
@@ -56,6 +57,7 @@ export const BUILD_IN_SERVERS: (ServerMetadata & { config: ServerConfig })[] =
maxLength: 32,
},
},
allowGuestDemoWorkspace: true,
},
},
]
@@ -88,6 +90,7 @@ export const BUILD_IN_SERVERS: (ServerMetadata & { config: ServerConfig })[] =
maxLength: 32,
},
},
allowGuestDemoWorkspace: true,
},
},
]
@@ -120,6 +123,7 @@ export const BUILD_IN_SERVERS: (ServerMetadata & { config: ServerConfig })[] =
maxLength: 32,
},
},
allowGuestDemoWorkspace: true,
},
},
]
@@ -148,6 +152,7 @@ export const BUILD_IN_SERVERS: (ServerMetadata & { config: ServerConfig })[] =
maxLength: 32,
},
},
allowGuestDemoWorkspace: true,
},
},
]
@@ -178,6 +183,7 @@ export const BUILD_IN_SERVERS: (ServerMetadata & { config: ServerConfig })[] =
maxLength: 32,
},
},
allowGuestDemoWorkspace: true,
},
},
]
@@ -82,6 +82,7 @@ export class Server extends Entity<{
credentialsRequirement: config.credentialsRequirement,
features: config.features,
oauthProviders: config.oauthProviders,
allowGuestDemoWorkspace: config.allowGuestDemoWorkspace,
serverName: config.name,
type: config.type,
version: config.version,
@@ -82,6 +82,7 @@ export class ServersService extends Service {
credentialsRequirement: config.credentialsRequirement,
features: config.features,
oauthProviders: config.oauthProviders,
allowGuestDemoWorkspace: config.allowGuestDemoWorkspace,
serverName: config.name,
type: config.type,
initialized: config.initialized,
@@ -14,6 +14,7 @@ export interface ServerMetadata {
export interface ServerConfig {
serverName: string;
features: ServerFeature[];
allowGuestDemoWorkspace: boolean;
oauthProviders: OAuthProviderType[];
type: ServerDeploymentType;
initialized?: boolean;
@@ -1,7 +1,6 @@
import type { FlagInfo } from './types';
// const isNotStableBuild = BUILD_CONFIG.appBuildType !== 'stable';
const isDesktopEnvironment = BUILD_CONFIG.isElectron;
const isCanaryBuild = BUILD_CONFIG.appBuildType === 'canary';
const isMobile = BUILD_CONFIG.isMobileEdition;
@@ -149,15 +148,6 @@ export const AFFINE_FLAGS = {
configurable: isCanaryBuild && !isMobile,
defaultState: isCanaryBuild,
},
enable_local_workspace: {
category: 'affine',
displayName:
'com.affine.settings.workspace.experimental-features.enable-local-workspace.name',
description:
'com.affine.settings.workspace.experimental-features.enable-local-workspace.description',
configurable: isCanaryBuild,
defaultState: isDesktopEnvironment || isCanaryBuild,
},
enable_advanced_block_visibility: {
category: 'blocksuite',
bsFlag: 'enable_advanced_block_visibility',