feat(auth): support tenantless provisioning and gated self-service workspace creation
Allow deployments to register users without auto-creating a personal tenant, expose creation policy via /auth/me, and guide tenantless accounts through a workspace onboarding flow.
This commit is contained in:
@@ -52,7 +52,7 @@ const syncOIDCUserContext = async () => {
|
||||
throw new Error(currentUserResponse.message || 'Failed to get user information')
|
||||
}
|
||||
|
||||
const { user, tenant, memberships } = currentUserResponse.data
|
||||
const { user, tenant, memberships, capabilities } = currentUserResponse.data
|
||||
authStore.setUser(userInfoFromApi(user, tenant?.id))
|
||||
if (tenant) {
|
||||
authStore.setTenant({
|
||||
@@ -67,6 +67,8 @@ const syncOIDCUserContext = async () => {
|
||||
created_at: tenant.created_at || new Date().toISOString(),
|
||||
updated_at: tenant.updated_at || new Date().toISOString()
|
||||
})
|
||||
} else {
|
||||
authStore.setTenant(null)
|
||||
}
|
||||
// Refresh memberships so currentTenantRole reflects any role change
|
||||
// since the last login (e.g. an Owner demoted us to Viewer in a
|
||||
@@ -75,6 +77,9 @@ const syncOIDCUserContext = async () => {
|
||||
if (Array.isArray(memberships)) {
|
||||
authStore.setMemberships(memberships)
|
||||
}
|
||||
if (typeof capabilities?.can_create_tenant === 'boolean') {
|
||||
authStore.setCanCreateTenant(capabilities.can_create_tenant)
|
||||
}
|
||||
// Same active-vs-home reconciliation as Login.vue: if the OIDC login
|
||||
// landed us in a non-home tenant (because the backend honoured a
|
||||
// remembered last-active-tenant preference) make sure X-Tenant-ID
|
||||
@@ -101,7 +106,7 @@ const persistOIDCLoginResponse = async (response: any) => {
|
||||
await syncOIDCUserContext()
|
||||
|
||||
await nextTick()
|
||||
router.replace('/platform/knowledge-bases')
|
||||
router.replace(authStore.hasValidTenant ? '/platform/knowledge-bases' : '/onboarding/workspace')
|
||||
}
|
||||
|
||||
const handleGlobalOIDCCallback = async () => {
|
||||
|
||||
@@ -34,7 +34,7 @@ export interface LoginResponse {
|
||||
storage_used: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
} | null
|
||||
// active_tenant mirrors `tenant` for endpoints that distinguish home
|
||||
// tenant from current tenant (e.g. /auth/register-by-invite). Only
|
||||
// one of `tenant` / `active_tenant` is populated by any given endpoint.
|
||||
@@ -48,7 +48,8 @@ export interface LoginResponse {
|
||||
storage_used?: number
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
}
|
||||
} | null
|
||||
memberships?: MembershipInfo[]
|
||||
token?: string
|
||||
refresh_token?: string
|
||||
}
|
||||
@@ -137,10 +138,11 @@ export function userInfoFromApi(
|
||||
u: any,
|
||||
fallbackTenantId?: string | number | null,
|
||||
): UserInfo {
|
||||
const tid =
|
||||
const rawTenantId =
|
||||
u?.tenant_id !== undefined && u?.tenant_id !== null && u.tenant_id !== ''
|
||||
? u.tenant_id
|
||||
: fallbackTenantId ?? ''
|
||||
const tid = Number(rawTenantId) > 0 ? rawTenantId : ''
|
||||
return {
|
||||
id: u?.id || '',
|
||||
username: u?.username || '',
|
||||
@@ -316,10 +318,14 @@ export interface MembershipInfo {
|
||||
/**
|
||||
* 获取当前用户信息
|
||||
*/
|
||||
export async function getCurrentUser(): Promise<{ success: boolean; data?: { user: UserInfo; tenant?: TenantInfo | null; memberships?: MembershipInfo[] }; message?: string }> {
|
||||
export interface AuthCapabilities {
|
||||
can_create_tenant: boolean
|
||||
}
|
||||
|
||||
export async function getCurrentUser(): Promise<{ success: boolean; data?: { user: UserInfo; tenant?: TenantInfo | null; memberships?: MembershipInfo[]; tenant_required?: boolean; capabilities?: AuthCapabilities }; message?: string }> {
|
||||
try {
|
||||
const response = await get('/api/v1/auth/me')
|
||||
return response as unknown as { success: boolean; data?: { user: UserInfo; tenant?: TenantInfo | null; memberships?: MembershipInfo[] }; message?: string }
|
||||
return response as unknown as { success: boolean; data?: { user: UserInfo; tenant?: TenantInfo | null; memberships?: MembershipInfo[]; tenant_required?: boolean; capabilities?: AuthCapabilities }; message?: string }
|
||||
} catch (error: any) {
|
||||
return {
|
||||
success: false,
|
||||
|
||||
@@ -284,9 +284,12 @@ export async function createTenant(
|
||||
const response = await post('/api/v1/tenants', payload)
|
||||
return response as unknown as { success: boolean; data?: TenantInfo; message?: string }
|
||||
} catch (error: any) {
|
||||
const code = error?.error?.code ?? error?.code
|
||||
return {
|
||||
success: false,
|
||||
message: error.message || t('error.tenant.createFailed'),
|
||||
message: code === 2005
|
||||
? t('tenant.create.disabled')
|
||||
: (error.message || t('error.tenant.createFailed')),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,9 +53,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 自助创建新工作区入口:任意已登录用户可点击,后端会把当前用户
|
||||
写成新租户的 Owner(见 internal/handler/tenant.go CreateTenant)。 -->
|
||||
<div class="tenant-create-action" @click="openCreateDialog">
|
||||
<!-- 自助创建入口与 /auth/me 返回的后端能力保持一致。 -->
|
||||
<div v-if="authStore.canCreateTenant" class="tenant-create-action" @click="openCreateDialog">
|
||||
<t-icon name="add" class="tenant-create-icon" />
|
||||
<span class="tenant-create-label">{{ $t('tenant.create.action') }}</span>
|
||||
</div>
|
||||
@@ -276,6 +275,10 @@ const createDialogVisible = ref(false)
|
||||
|
||||
const openCreateDialog = () => {
|
||||
closeDropdown()
|
||||
if (!authStore.canCreateTenant) {
|
||||
MessagePlugin.info(t('tenant.create.disabled'))
|
||||
return
|
||||
}
|
||||
createDialogVisible.value = true
|
||||
}
|
||||
|
||||
|
||||
@@ -185,11 +185,8 @@
|
||||
{{ $t('tenant.switcher.empty') }}
|
||||
</div>
|
||||
</div>
|
||||
<!-- 自助创建新工作区入口:放在租户列表底部,所有能 hover 出这个
|
||||
子菜单的用户都能看到(包括单租户用户)。后端 router 已对
|
||||
POST /api/v1/tenants 去掉跨租户超管守卫,handler 内部会把
|
||||
当前用户 EnsureOwner 成新租户的 Owner。 -->
|
||||
<div class="tenant-submenu-create" @click="openCreateTenantDialog">
|
||||
<!-- 自助创建入口与 /auth/me 返回的后端能力保持一致。 -->
|
||||
<div v-if="authStore.canCreateTenant" class="tenant-submenu-create" @click="openCreateTenantDialog">
|
||||
<t-icon name="add" class="tenant-submenu-create-icon" />
|
||||
<span class="tenant-submenu-create-label">{{ $t('tenant.create.action') }}</span>
|
||||
</div>
|
||||
@@ -344,6 +341,10 @@ const createTenantDialogVisible = ref(false)
|
||||
|
||||
const openCreateTenantDialog = () => {
|
||||
closeAll()
|
||||
if (!authStore.canCreateTenant) {
|
||||
MessagePlugin.info(t('tenant.create.disabled'))
|
||||
return
|
||||
}
|
||||
createTenantDialogVisible.value = true
|
||||
}
|
||||
|
||||
@@ -569,6 +570,10 @@ const loadUserInfo = async () => {
|
||||
if (Array.isArray(membershipsSync)) {
|
||||
authStore.setMemberships(membershipsSync)
|
||||
}
|
||||
const canCreateTenant = response.data.capabilities?.can_create_tenant
|
||||
if (typeof canCreateTenant === 'boolean') {
|
||||
authStore.setCanCreateTenant(canCreateTenant)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load user info:', error)
|
||||
|
||||
@@ -1944,10 +1944,10 @@ export default {
|
||||
registerNow: 'Register Now',
|
||||
loginHint: 'Sign in to continue, or create an account below if this is your first time.',
|
||||
firstTime: 'New to WeKnora?',
|
||||
registerSuccess: 'Registration successful! The system has created an exclusive tenant for you, please login',
|
||||
registerSuccess: 'Registration successful. Please sign in',
|
||||
registerFailed: 'Registration failed',
|
||||
subtitle: 'RAG Q&A, ReAct Agent and Wiki — an LLM-powered enterprise knowledge framework',
|
||||
registerSubtitle: 'The system will create an exclusive tenant for you after registration',
|
||||
registerSubtitle: 'Create your account and start using WeKnora',
|
||||
emailPlaceholder: 'Enter email address',
|
||||
passwordPlaceholder: 'Enter password (8-32 characters, including letters and numbers)',
|
||||
confirmPasswordPlaceholder: 'Enter password again',
|
||||
@@ -1968,7 +1968,21 @@ export default {
|
||||
loginError: 'Login error, please check email or password',
|
||||
loginErrorRetry: 'Login error, please try again later',
|
||||
registerError: 'Registration error, please try again later',
|
||||
forgotPasswordNotAvailable: 'Password recovery function is temporarily unavailable, please contact administrator'
|
||||
forgotPasswordNotAvailable: 'Password recovery function is temporarily unavailable, please contact administrator',
|
||||
workspaceOnboarding: {
|
||||
title: 'Choose your workspace',
|
||||
description: 'Your account does not belong to a workspace yet. Create one or accept an invitation from an administrator.',
|
||||
create: 'Create workspace',
|
||||
invitations: 'View invitations',
|
||||
help: 'If no invitation is available, ask a system administrator to add you to an existing workspace.',
|
||||
loadingPolicy: 'Checking the available workspace options…',
|
||||
policyLoadFailed: 'Workspace permissions could not be loaded. Check your connection and try again.',
|
||||
retry: 'Reload',
|
||||
inviteOnlyTitle: 'Waiting for a workspace invitation',
|
||||
inviteOnlyDescription: 'Personal workspace creation is disabled. View and accept an invitation from a workspace administrator.',
|
||||
inviteOnlyNotice: 'This account can only join an existing workspace by invitation',
|
||||
inviteOnlyHelp: 'No invitation yet? Send your registered email address to a workspace administrator and ask them to invite you.',
|
||||
}
|
||||
},
|
||||
authStore: {
|
||||
errors: {
|
||||
@@ -3316,6 +3330,7 @@ export default {
|
||||
cancel: 'Cancel',
|
||||
success: 'Workspace created successfully',
|
||||
failed: 'Failed to create workspace',
|
||||
disabled: 'This system only allows joining workspaces by invitation. You cannot create one yourself.',
|
||||
},
|
||||
details: {
|
||||
idLabel: 'Tenant ID',
|
||||
@@ -3584,12 +3599,14 @@ export default {
|
||||
keyLabels: {
|
||||
auth: {
|
||||
registration_mode: 'Self-service registration mode',
|
||||
default_tenant_mode: 'Default workspace provisioning',
|
||||
},
|
||||
ssrf: {
|
||||
whitelist: 'SSRF protection allowlist',
|
||||
},
|
||||
tenant: {
|
||||
max_owned_per_user: 'Max tenants owned per user',
|
||||
self_service_creation_enabled: 'Allow self-service workspace creation',
|
||||
default_storage_quota_gb: 'Default storage quota for new tenants (GB)',
|
||||
},
|
||||
asynq: {
|
||||
@@ -3608,6 +3625,8 @@ export default {
|
||||
auth: {
|
||||
registration_mode:
|
||||
'Self-service registration mode. self_serve = anyone can register an account; invite_only = public registration is disabled and only Owners/Admins can invite. Takes effect immediately after saving, but use self_serve with care (the public internet will send spam sign-ups).',
|
||||
default_tenant_mode:
|
||||
'Workspace provisioning after public registration. create_personal creates an Owner workspace; tenantless creates only the account until the user accepts an invitation or creates a workspace. Applies to new users only.',
|
||||
},
|
||||
ssrf: {
|
||||
whitelist:
|
||||
@@ -3616,6 +3635,8 @@ export default {
|
||||
tenant: {
|
||||
max_owned_per_user:
|
||||
'Maximum number of tenants a non-superuser may own via self-service creation. Read on every tenant creation and takes effect immediately after saving. 0 uses the built-in default of 10; a negative value disables the cap entirely (not recommended on public deployments).',
|
||||
self_service_creation_enabled:
|
||||
'Whether non-superusers may create workspaces themselves. When disabled, regular users can only join existing workspaces by invitation; cross-tenant superusers remain exempt. Takes effect immediately.',
|
||||
default_storage_quota_gb:
|
||||
'Default storage quota (GB) assigned when a new tenant is created, covering vectors, originals, text, indexes, and related data. Read only at creation time — changes apply to newly created tenants only and do not retroactively update existing tenants. 0 or a negative value uses the built-in default of 10 GB.',
|
||||
},
|
||||
@@ -3639,6 +3660,10 @@ export default {
|
||||
self_serve: 'Self-service (anyone can register)',
|
||||
invite_only: 'Invite only (public registration disabled)',
|
||||
},
|
||||
default_tenant_mode: {
|
||||
create_personal: 'Create personal workspace',
|
||||
tenantless: 'Do not create a workspace',
|
||||
},
|
||||
},
|
||||
},
|
||||
confirm: {
|
||||
|
||||
@@ -1794,10 +1794,10 @@ export default {
|
||||
registerNow: "지금 가입하기",
|
||||
loginHint: "로그인하여 계속하세요. 처음이시라면 아래에서 계정을 만드세요.",
|
||||
firstTime: "WeKnora가 처음이신가요?",
|
||||
registerSuccess: "가입 성공! 시스템이 전용 테넌트를 생성했습니다. 로그인해주세요",
|
||||
registerSuccess: "가입이 완료되었습니다. 로그인해주세요",
|
||||
registerFailed: "가입 실패",
|
||||
subtitle: "RAG Q&A, ReAct 에이전트, Wiki 지식베이스 — 대규모 언어 모델 기반 엔터프라이즈 지식 프레임워크",
|
||||
registerSubtitle: "가입 후 시스템이 전용 테넌트를 생성합니다",
|
||||
registerSubtitle: "계정을 만들고 WeKnora를 시작하세요",
|
||||
emailPlaceholder: "이메일 주소 입력",
|
||||
passwordPlaceholder: "비밀번호 입력 (8-32자, 문자와 숫자 포함)",
|
||||
confirmPasswordPlaceholder: "비밀번호 다시 입력",
|
||||
@@ -1820,6 +1820,20 @@ export default {
|
||||
registerError: "가입 오류, 나중에 다시 시도해주세요",
|
||||
forgotPasswordNotAvailable:
|
||||
"비밀번호 찾기 기능을 현재 사용할 수 없습니다. 관리자에게 문의해주세요",
|
||||
workspaceOnboarding: {
|
||||
title: "작업 공간 선택",
|
||||
description: "아직 참여한 공간이 없습니다. 새 공간을 만들거나 관리자의 초대를 수락하세요.",
|
||||
create: "공간 만들기",
|
||||
invitations: "초대 보기",
|
||||
help: "사용 가능한 초대가 없다면 시스템 관리자에게 기존 공간 추가를 요청하세요.",
|
||||
loadingPolicy: "사용 가능한 공간 참여 방식을 확인하고 있습니다…",
|
||||
policyLoadFailed: "공간 권한을 불러올 수 없습니다. 네트워크를 확인한 후 다시 시도하세요.",
|
||||
retry: "다시 불러오기",
|
||||
inviteOnlyTitle: "작업 공간 초대 대기",
|
||||
inviteOnlyDescription: "개인 공간 만들기가 비활성화되어 있습니다. 관리자가 보낸 초대를 확인하고 수락하세요.",
|
||||
inviteOnlyNotice: "이 계정은 초대를 통해서만 기존 공간에 참여할 수 있습니다",
|
||||
inviteOnlyHelp: "초대가 없다면 등록 이메일을 공간 관리자에게 전달하고 초대를 요청하세요.",
|
||||
},
|
||||
},
|
||||
authStore: {
|
||||
errors: {
|
||||
@@ -2312,6 +2326,7 @@ export default {
|
||||
cancel: "취소",
|
||||
success: "워크스페이스가 생성되었습니다",
|
||||
failed: "워크스페이스 생성 실패",
|
||||
disabled: "현재 시스템에서는 초대를 통해서만 공간에 참여할 수 있으며 직접 만들 수 없습니다.",
|
||||
},
|
||||
details: {
|
||||
idLabel: "테넌트 ID",
|
||||
@@ -2569,12 +2584,14 @@ export default {
|
||||
keyLabels: {
|
||||
auth: {
|
||||
registration_mode: "셀프 가입 모드",
|
||||
default_tenant_mode: "기본 공간 프로비저닝",
|
||||
},
|
||||
ssrf: {
|
||||
whitelist: "SSRF 보호 허용 목록",
|
||||
},
|
||||
tenant: {
|
||||
max_owned_per_user: "사용자당 최대 테넌트 수",
|
||||
self_service_creation_enabled: "사용자 공간 직접 생성 허용",
|
||||
default_storage_quota_gb: "신규 테넌트 기본 저장 용량 (GB)",
|
||||
},
|
||||
asynq: {
|
||||
@@ -2593,6 +2610,8 @@ export default {
|
||||
auth: {
|
||||
registration_mode:
|
||||
"셀프 가입 모드입니다. self_serve = 누구나 계정을 만들 수 있음; invite_only = 공개 가입을 끄고 Owner/Admin만 초대 가능. 저장 즉시 적용되며, self_serve는 스팸 가입이 들어올 수 있으니 신중히 사용하세요.",
|
||||
default_tenant_mode:
|
||||
"공개 가입 후 공간 초기화 정책입니다. create_personal은 개인 공간을 만들고 Owner를 부여하며, tenantless는 초대 수락 또는 직접 공간 생성 전까지 계정만 만듭니다.",
|
||||
},
|
||||
ssrf: {
|
||||
whitelist:
|
||||
@@ -2601,6 +2620,8 @@ export default {
|
||||
tenant: {
|
||||
max_owned_per_user:
|
||||
"슈퍼유저가 아닌 사용자가 셀프 서비스로 소유할 수 있는 최대 테넌트 수입니다. 테넌트 생성 시마다 읽으며 저장 즉시 적용됩니다. 0은 내장 기본값 10을 사용하고, 음수는 제한을 완전히 해제합니다(공개 배포에는 권장하지 않음).",
|
||||
self_service_creation_enabled:
|
||||
"비슈퍼유저가 공간을 직접 만들 수 있는지 설정합니다. 비활성화하면 일반 사용자는 초대로만 기존 공간에 참여할 수 있으며, 크로스 테넌트 슈퍼유저는 계속 만들 수 있습니다.",
|
||||
default_storage_quota_gb:
|
||||
"신규 테넌트 생성 시 기본으로 할당되는 저장 용량(GB)으로, 벡터·원본·텍스트·인덱스 등을 포함합니다. 생성 시에만 읽으며, 변경은 이후 생성되는 테넌트에만 적용되고 기존 테넌트에는 소급되지 않습니다. 0 또는 음수는 내장 기본값 10GB를 사용합니다.",
|
||||
},
|
||||
@@ -2624,6 +2645,10 @@ export default {
|
||||
self_serve: "셀프 가입 (누구나 가입 가능)",
|
||||
invite_only: "초대 전용 (공개 가입 비활성)",
|
||||
},
|
||||
default_tenant_mode: {
|
||||
create_personal: "개인 공간 자동 생성",
|
||||
tenantless: "공간을 자동 생성하지 않음",
|
||||
},
|
||||
},
|
||||
},
|
||||
confirm: {
|
||||
|
||||
@@ -1814,10 +1814,10 @@ export default {
|
||||
registerNow: 'Зарегистрироваться',
|
||||
loginHint: 'Войдите, чтобы продолжить, или создайте аккаунт ниже, если вы впервые здесь.',
|
||||
firstTime: 'Впервые в WeKnora?',
|
||||
registerSuccess: 'Регистрация успешна! Система создала для вас эксклюзивного арендатора, пожалуйста, войдите',
|
||||
registerSuccess: 'Регистрация завершена. Войдите в систему',
|
||||
registerFailed: 'Ошибка регистрации',
|
||||
subtitle: 'RAG, ReAct-агент и Wiki — корпоративный фреймворк знаний на основе больших моделей',
|
||||
registerSubtitle: 'После регистрации система создаст для вас эксклюзивного арендатора',
|
||||
registerSubtitle: 'Создайте аккаунт и начните работу с WeKnora',
|
||||
emailPlaceholder: 'Введите адрес электронной почты',
|
||||
passwordPlaceholder: 'Введите пароль (8-32 символа, включая буквы и цифры)',
|
||||
confirmPasswordPlaceholder: 'Введите пароль ещё раз',
|
||||
@@ -1838,7 +1838,21 @@ export default {
|
||||
loginError: 'Ошибка входа, пожалуйста, проверьте электронную почту или пароль',
|
||||
loginErrorRetry: 'Ошибка входа, пожалуйста, повторите попытку позже',
|
||||
registerError: 'Ошибка регистрации, пожалуйста, повторите попытку позже',
|
||||
forgotPasswordNotAvailable: 'Функция восстановления пароля временно недоступна, пожалуйста, свяжитесь с администратором'
|
||||
forgotPasswordNotAvailable: 'Функция восстановления пароля временно недоступна, пожалуйста, свяжитесь с администратором',
|
||||
workspaceOnboarding: {
|
||||
title: 'Выберите рабочее пространство',
|
||||
description: 'Ваш аккаунт пока не состоит ни в одном пространстве. Создайте новое или примите приглашение администратора.',
|
||||
create: 'Создать пространство',
|
||||
invitations: 'Посмотреть приглашения',
|
||||
help: 'Если приглашений нет, попросите системного администратора добавить вас в существующее пространство.',
|
||||
loadingPolicy: 'Проверяем доступные способы присоединения…',
|
||||
policyLoadFailed: 'Не удалось загрузить разрешения пространства. Проверьте подключение и повторите попытку.',
|
||||
retry: 'Повторить',
|
||||
inviteOnlyTitle: 'Ожидание приглашения в пространство',
|
||||
inviteOnlyDescription: 'Создание личных пространств отключено. Просмотрите и примите приглашение администратора.',
|
||||
inviteOnlyNotice: 'Этот аккаунт может присоединиться к существующему пространству только по приглашению',
|
||||
inviteOnlyHelp: 'Нет приглашения? Сообщите администратору пространства свой регистрационный адрес электронной почты.',
|
||||
}
|
||||
},
|
||||
authStore: {
|
||||
errors: {
|
||||
@@ -2011,6 +2025,7 @@ export default {
|
||||
cancel: 'Отмена',
|
||||
success: 'Рабочее пространство создано',
|
||||
failed: 'Не удалось создать рабочее пространство',
|
||||
disabled: 'В этой системе присоединиться к пространству можно только по приглашению; создать его самостоятельно нельзя.',
|
||||
},
|
||||
details: {
|
||||
idLabel: 'ID арендатора',
|
||||
@@ -2267,12 +2282,14 @@ export default {
|
||||
keyLabels: {
|
||||
auth: {
|
||||
registration_mode: 'Режим самостоятельной регистрации',
|
||||
default_tenant_mode: 'Создание пространства по умолчанию',
|
||||
},
|
||||
ssrf: {
|
||||
whitelist: 'Белый список SSRF-защиты',
|
||||
},
|
||||
tenant: {
|
||||
max_owned_per_user: 'Максимум тенантов на пользователя',
|
||||
self_service_creation_enabled: 'Разрешить самостоятельное создание пространств',
|
||||
default_storage_quota_gb: 'Квота хранилища для новых тенантов по умолчанию (ГБ)',
|
||||
},
|
||||
asynq: {
|
||||
@@ -2291,6 +2308,8 @@ export default {
|
||||
auth: {
|
||||
registration_mode:
|
||||
'Режим самостоятельной регистрации. self_serve = любой может создать аккаунт; invite_only = открытая регистрация отключена, приглашать могут только Owner/Admin. Вступает в силу сразу после сохранения; используйте self_serve осторожно (в публичном интернете появятся спам-регистрации).',
|
||||
default_tenant_mode:
|
||||
'Политика пространства после открытой регистрации. create_personal создаёт личное пространство с ролью Owner; tenantless создаёт только аккаунт до принятия приглашения или самостоятельного создания пространства.',
|
||||
},
|
||||
ssrf: {
|
||||
whitelist:
|
||||
@@ -2299,6 +2318,8 @@ export default {
|
||||
tenant: {
|
||||
max_owned_per_user:
|
||||
'Максимальное число тенантов, которыми может владеть обычный (не супер) пользователь через самостоятельное создание. Читается при каждом создании тенанта и вступает в силу сразу после сохранения. 0 — встроенное значение по умолчанию 10; отрицательное значение полностью снимает ограничение (не рекомендуется для публичных развёртываний).',
|
||||
self_service_creation_enabled:
|
||||
'Разрешает обычным пользователям самостоятельно создавать пространства. Если отключено, они могут только присоединяться по приглашению; межтенантные суперпользователи не ограничены.',
|
||||
default_storage_quota_gb:
|
||||
'Квота хранилища по умолчанию (ГБ) для нового тенанта: векторы, оригиналы, текст, индексы и т.д. Читается только при создании — изменения применяются только к новым тенантам и не перезаписывают существующие. 0 или отрицательное значение — встроенное значение по умолчанию 10 ГБ.',
|
||||
},
|
||||
@@ -2322,6 +2343,10 @@ export default {
|
||||
self_serve: 'Самостоятельная (любой может зарегистрироваться)',
|
||||
invite_only: 'Только по приглашению (открытая регистрация отключена)',
|
||||
},
|
||||
default_tenant_mode: {
|
||||
create_personal: 'Создавать личное пространство',
|
||||
tenantless: 'Не создавать пространство',
|
||||
},
|
||||
},
|
||||
},
|
||||
confirm: {
|
||||
|
||||
@@ -1801,10 +1801,10 @@ export default {
|
||||
registerNow: "立即注册",
|
||||
loginHint: "登录以继续使用;首次使用请在下方创建账户。",
|
||||
firstTime: "首次使用 WeKnora?",
|
||||
registerSuccess: "注册成功!系统已为您创建专属空间,请登录",
|
||||
registerSuccess: "注册成功,请登录",
|
||||
registerFailed: "注册失败",
|
||||
subtitle: "RAG 问答、ReAct 智能体与 Wiki 知识库,大模型驱动的企业级知识框架",
|
||||
registerSubtitle: "注册后系统将为您创建专属空间",
|
||||
registerSubtitle: "创建账户并开始使用 WeKnora",
|
||||
emailPlaceholder: "输入邮箱地址",
|
||||
passwordPlaceholder: "输入密码(8-32个字符,包含字母和数字)",
|
||||
confirmPasswordPlaceholder: "再次输入密码",
|
||||
@@ -1826,6 +1826,20 @@ export default {
|
||||
loginErrorRetry: "登录错误,请稍后重试",
|
||||
registerError: "注册错误,请稍后重试",
|
||||
forgotPasswordNotAvailable: "密码找回功能暂不可用,请联系管理员",
|
||||
workspaceOnboarding: {
|
||||
title: "选择你的工作空间",
|
||||
description: "你的账户尚未加入任何空间。你可以创建一个新空间,或接受管理员发来的邀请。",
|
||||
create: "创建空间",
|
||||
invitations: "查看邀请",
|
||||
help: "如果这里没有可用邀请,请联系系统管理员将你加入现有空间。",
|
||||
loadingPolicy: "正在确认可用的空间加入方式…",
|
||||
policyLoadFailed: "暂时无法获取空间权限,请检查网络后重试。",
|
||||
retry: "重新加载",
|
||||
inviteOnlyTitle: "等待加入工作空间",
|
||||
inviteOnlyDescription: "当前系统不开放个人创建空间。你可以查看并接受管理员发来的空间邀请。",
|
||||
inviteOnlyNotice: "此账户只能通过邀请加入已有空间",
|
||||
inviteOnlyHelp: "还没有邀请?请把你的注册邮箱提供给空间管理员,由管理员向你发送邀请。",
|
||||
},
|
||||
},
|
||||
authStore: {
|
||||
errors: {
|
||||
@@ -2304,6 +2318,7 @@ export default {
|
||||
cancel: "取消",
|
||||
success: "空间创建成功",
|
||||
failed: "空间创建失败",
|
||||
disabled: "当前系统只允许通过邀请加入空间,不能自行创建空间。",
|
||||
},
|
||||
details: {
|
||||
idLabel: "空间 ID",
|
||||
@@ -2572,12 +2587,14 @@ export default {
|
||||
keyLabels: {
|
||||
auth: {
|
||||
registration_mode: "自助注册模式",
|
||||
default_tenant_mode: "注册默认空间策略",
|
||||
},
|
||||
ssrf: {
|
||||
whitelist: "SSRF 防护白名单",
|
||||
},
|
||||
tenant: {
|
||||
max_owned_per_user: "每用户最大租户数",
|
||||
self_service_creation_enabled: "允许用户自助创建空间",
|
||||
default_storage_quota_gb: "新租户默认存储配额 (GB)",
|
||||
},
|
||||
asynq: {
|
||||
@@ -2597,6 +2614,9 @@ export default {
|
||||
registration_mode:
|
||||
"自助注册模式。self_serve = 任何人可注册账号;invite_only = 关闭公网注册," +
|
||||
"仅 Owner/Admin 可邀请。修改后立即生效,但谨慎对待 self_serve(公网会接受 spam)。",
|
||||
default_tenant_mode:
|
||||
"公开注册后的空间初始化策略。create_personal 会自动创建个人空间并授予 Owner;" +
|
||||
"tenantless 仅创建账户,用户需要接受邀请或主动创建空间。只影响之后注册的用户。",
|
||||
},
|
||||
ssrf: {
|
||||
whitelist:
|
||||
@@ -2607,6 +2627,9 @@ export default {
|
||||
max_owned_per_user:
|
||||
"每个非超管用户通过自助创建可拥有的最大租户数。每次创建租户时实时读取," +
|
||||
"修改后立即生效。0 表示使用内置默认值 10;负数表示完全关闭限制(不建议在公开部署使用)。",
|
||||
self_service_creation_enabled:
|
||||
"是否允许非超管用户主动创建空间。关闭后,普通用户只能通过邀请加入已有空间;" +
|
||||
"跨租户超管仍可创建。修改后立即生效。",
|
||||
default_storage_quota_gb:
|
||||
"新建租户时默认分配的存储配额(GB),包含向量、原文、文本、索引等。" +
|
||||
"仅在创建时读取,修改后只对之后新建的租户生效,不会回写已存在的租户。" +
|
||||
@@ -2635,6 +2658,10 @@ export default {
|
||||
self_serve: "自助注册(任何人可注册)",
|
||||
invite_only: "仅邀请(关闭公网注册)",
|
||||
},
|
||||
default_tenant_mode: {
|
||||
create_personal: "自动创建个人空间",
|
||||
tenantless: "不自动创建空间",
|
||||
},
|
||||
},
|
||||
},
|
||||
confirm: {
|
||||
|
||||
@@ -63,6 +63,12 @@ const router = createRouter({
|
||||
component: () => import("../views/auth/Login.vue"),
|
||||
meta: { requiresAuth: false, requiresInit: false }
|
||||
},
|
||||
{
|
||||
path: "/onboarding/workspace",
|
||||
name: "workspaceOnboarding",
|
||||
component: () => import("../views/auth/WorkspaceOnboarding.vue"),
|
||||
meta: { requiresAuth: true, requiresInit: false, requiresTenant: false }
|
||||
},
|
||||
{
|
||||
path: "/join",
|
||||
name: "joinOrganization",
|
||||
@@ -256,6 +262,8 @@ async function hydrateSessionFromToken(authStore: ReturnType<typeof useAuthStore
|
||||
created_at: tenant.created_at || new Date().toISOString(),
|
||||
updated_at: tenant.updated_at || new Date().toISOString(),
|
||||
})
|
||||
} else {
|
||||
authStore.setTenant(null)
|
||||
}
|
||||
|
||||
// Refresh memberships on every page load — same reason as
|
||||
@@ -268,6 +276,11 @@ async function hydrateSessionFromToken(authStore: ReturnType<typeof useAuthStore
|
||||
authStore.setMemberships(memberships)
|
||||
}
|
||||
|
||||
const canCreateTenant = response.data?.capabilities?.can_create_tenant
|
||||
if (typeof canCreateTenant === 'boolean') {
|
||||
authStore.setCanCreateTenant(canCreateTenant)
|
||||
}
|
||||
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
@@ -302,11 +315,29 @@ router.beforeEach(async (to, from, next) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Tenantless onboarding still requires a valid user token even though it
|
||||
// deliberately skips the normal tenant/system-initialization gates.
|
||||
if (to.path === '/onboarding/workspace') {
|
||||
if (!authStore.isLoggedIn) {
|
||||
const restored = await hydrateSessionFromToken(authStore)
|
||||
if (!restored) {
|
||||
next('/login')
|
||||
return
|
||||
}
|
||||
}
|
||||
if (authStore.hasValidTenant) {
|
||||
next('/platform/knowledge-bases')
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 如果访问的是登录页面或初始化页面,直接放行
|
||||
if (to.meta.requiresAuth === false || to.meta.requiresInit === false) {
|
||||
// 如果已登录用户访问登录页面,重定向到知识库列表页面
|
||||
if (to.path === '/login' && authStore.isLoggedIn) {
|
||||
next('/platform/knowledge-bases')
|
||||
next(authStore.hasValidTenant ? '/platform/knowledge-bases' : '/onboarding/workspace')
|
||||
return
|
||||
}
|
||||
next()
|
||||
@@ -318,7 +349,11 @@ router.beforeEach(async (to, from, next) => {
|
||||
if (!authStore.isLoggedIn) {
|
||||
const restored = await hydrateSessionFromToken(authStore)
|
||||
if (restored) {
|
||||
next(to.fullPath)
|
||||
next(
|
||||
!authStore.hasValidTenant && to.meta.requiresTenant !== false
|
||||
? '/onboarding/workspace'
|
||||
: to.fullPath,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -343,6 +378,11 @@ router.beforeEach(async (to, from, next) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (to.meta.requiresTenant !== false && !authStore.hasValidTenant) {
|
||||
next('/onboarding/workspace')
|
||||
return
|
||||
}
|
||||
|
||||
// SystemAdmin gate — checked AFTER auth so a non-admin who's logged
|
||||
// out gets redirected to /login first (consistent with how the rest
|
||||
// of the auth flow works), and only an authenticated non-admin sees
|
||||
|
||||
@@ -52,6 +52,9 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
// (vs SSE) is fine — the count is checked rarely and a 1-2 minute
|
||||
// staleness window is acceptable for an inbox indicator.
|
||||
const pendingInvitationCount = ref<number>(0)
|
||||
// Authoritative deployment capability returned by /auth/me. Defaults to
|
||||
// true for compatibility with older backends that do not return it yet.
|
||||
const canCreateTenant = ref(true)
|
||||
|
||||
// 计算属性
|
||||
const isLoggedIn = computed(() => {
|
||||
@@ -199,10 +202,14 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
}
|
||||
}
|
||||
|
||||
const setTenant = (tenantData: TenantInfo) => {
|
||||
const setTenant = (tenantData: TenantInfo | null) => {
|
||||
tenant.value = tenantData
|
||||
// 保存到localStorage
|
||||
localStorage.setItem('weknora_tenant', JSON.stringify(tenantData))
|
||||
if (tenantData) {
|
||||
localStorage.setItem('weknora_tenant', JSON.stringify(tenantData))
|
||||
} else {
|
||||
localStorage.removeItem('weknora_tenant')
|
||||
setSelectedTenant(null, null)
|
||||
}
|
||||
}
|
||||
|
||||
const setToken = (tokenValue: string) => {
|
||||
@@ -303,6 +310,10 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
pendingInvitationCount.value = Number.isFinite(n) && n >= 0 ? Math.floor(n) : 0
|
||||
}
|
||||
|
||||
const setCanCreateTenant = (allowed: boolean) => {
|
||||
canCreateTenant.value = allowed
|
||||
}
|
||||
|
||||
// fetchPendingInvitationCount hits the dedicated /me/invitations/
|
||||
// pending-count endpoint and updates the store. Errors are
|
||||
// swallowed — the badge degrades to its last-known value instead
|
||||
@@ -351,6 +362,8 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
created_at: tenantSnapshot.created_at || new Date().toISOString(),
|
||||
updated_at: tenantSnapshot.updated_at || new Date().toISOString(),
|
||||
})
|
||||
} else {
|
||||
setTenant(null)
|
||||
}
|
||||
|
||||
const list = response.data?.memberships
|
||||
@@ -358,6 +371,11 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
setMemberships(list)
|
||||
}
|
||||
|
||||
const createCapability = response.data?.capabilities?.can_create_tenant
|
||||
if (typeof createCapability === 'boolean') {
|
||||
setCanCreateTenant(createCapability)
|
||||
}
|
||||
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
@@ -390,6 +408,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
allTenants.value = []
|
||||
memberships.value = []
|
||||
pendingInvitationCount.value = 0
|
||||
canCreateTenant.value = true
|
||||
clearSessionResourceCaches()
|
||||
|
||||
// 清空localStorage
|
||||
@@ -512,6 +531,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
allTenants,
|
||||
memberships,
|
||||
pendingInvitationCount,
|
||||
canCreateTenant,
|
||||
|
||||
// 计算属性
|
||||
isLoggedIn,
|
||||
@@ -537,6 +557,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
setAllTenants,
|
||||
setMemberships,
|
||||
setPendingInvitationCount,
|
||||
setCanCreateTenant,
|
||||
fetchPendingInvitationCount,
|
||||
refreshFromAuthMe,
|
||||
getSelectedTenant,
|
||||
|
||||
@@ -24,8 +24,8 @@ interface LoginResponseLike {
|
||||
// Password-login response uses `active_tenant`; the OIDC callback
|
||||
// response uses `tenant` (legacy backward-compat name on the Go side).
|
||||
// Accept either so callers don't have to normalise.
|
||||
active_tenant?: { id?: number | string; name?: string }
|
||||
tenant?: { id?: number | string; name?: string }
|
||||
active_tenant?: { id?: number | string; name?: string } | null
|
||||
tenant?: { id?: number | string; name?: string } | null
|
||||
memberships?: Array<{ tenant_id?: number | string; role?: string }>
|
||||
}
|
||||
|
||||
|
||||
@@ -538,25 +538,29 @@ const persistLoginResponse = async (response: any) => {
|
||||
// identical — `active_tenant` is the tenant whose ID is encoded in the
|
||||
// JWT, defaulting to the user's home tenant on a fresh login.
|
||||
const activeTenant = response.active_tenant || response.tenant
|
||||
if (response.user && activeTenant && response.token) {
|
||||
if (response.user && response.token) {
|
||||
// user.tenant_id must be the user's HOME tenant (the immutable row
|
||||
// on the users table); useHomeTenant() and the home-badge logic both
|
||||
// assume so. The ACTIVE tenant (which can differ from home when the
|
||||
// server honoured a remembered last-active-tenant preference) is
|
||||
// expressed separately via setSelectedTenant below.
|
||||
const homeTenantIdRaw = response.user.tenant_id ?? activeTenant.id
|
||||
const homeTenantIdRaw = response.user.tenant_id ?? activeTenant?.id ?? ''
|
||||
authStore.setUser(userInfoFromApi(response.user, homeTenantIdRaw))
|
||||
authStore.setToken(response.token)
|
||||
if (response.refresh_token) {
|
||||
authStore.setRefreshToken(response.refresh_token)
|
||||
}
|
||||
authStore.setTenant({
|
||||
id: String(activeTenant.id) || '',
|
||||
name: activeTenant.name || '',
|
||||
owner_id: response.user.id || '',
|
||||
created_at: activeTenant.created_at || new Date().toISOString(),
|
||||
updated_at: activeTenant.updated_at || new Date().toISOString()
|
||||
})
|
||||
if (activeTenant) {
|
||||
authStore.setTenant({
|
||||
id: String(activeTenant.id) || '',
|
||||
name: activeTenant.name || '',
|
||||
owner_id: response.user.id || '',
|
||||
created_at: activeTenant.created_at || new Date().toISOString(),
|
||||
updated_at: activeTenant.updated_at || new Date().toISOString()
|
||||
})
|
||||
} else {
|
||||
authStore.setTenant(null)
|
||||
}
|
||||
if (Array.isArray(response.memberships)) {
|
||||
authStore.setMemberships(response.memberships)
|
||||
}
|
||||
@@ -565,17 +569,21 @@ const persistLoginResponse = async (response: any) => {
|
||||
// subsequent requests carry X-Tenant-ID and the UI stays consistent.
|
||||
// Otherwise clear any stale override left in localStorage by a
|
||||
// previous session for a different account.
|
||||
const activeIdNum = Number(activeTenant.id)
|
||||
const activeIdNum = Number(activeTenant?.id)
|
||||
const homeIdNum = Number(homeTenantIdRaw)
|
||||
if (Number.isFinite(activeIdNum) && Number.isFinite(homeIdNum) && activeIdNum !== homeIdNum) {
|
||||
authStore.setSelectedTenant(activeIdNum, activeTenant.name || null)
|
||||
authStore.setSelectedTenant(activeIdNum, activeTenant?.name || null)
|
||||
} else {
|
||||
authStore.setSelectedTenant(null, null)
|
||||
}
|
||||
}
|
||||
|
||||
// Pull runtime capabilities (including whether ordinary users may create
|
||||
// workspaces) before entering the main UI so create actions never flash
|
||||
// briefly when the deployment is invitation-only.
|
||||
await authStore.refreshFromAuthMe()
|
||||
await nextTick()
|
||||
router.replace('/platform/knowledge-bases')
|
||||
router.replace(authStore.hasValidTenant ? '/platform/knowledge-bases' : '/onboarding/workspace')
|
||||
}
|
||||
|
||||
const getBackendOIDCRedirectURI = () => `${window.location.origin}/api/v1/auth/oidc/callback`
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
<template>
|
||||
<main class="workspace-onboarding">
|
||||
<section class="workspace-card">
|
||||
<div class="workspace-mark" aria-hidden="true">
|
||||
<t-icon name="system-sum" size="30px" />
|
||||
</div>
|
||||
<h1>
|
||||
{{
|
||||
$t(
|
||||
authStore.canCreateTenant
|
||||
? 'auth.workspaceOnboarding.title'
|
||||
: 'auth.workspaceOnboarding.inviteOnlyTitle',
|
||||
)
|
||||
}}
|
||||
</h1>
|
||||
<p class="workspace-description">
|
||||
{{
|
||||
$t(
|
||||
authStore.canCreateTenant
|
||||
? 'auth.workspaceOnboarding.description'
|
||||
: 'auth.workspaceOnboarding.inviteOnlyDescription',
|
||||
)
|
||||
}}
|
||||
</p>
|
||||
|
||||
<div v-if="policyLoading" class="policy-loading">
|
||||
<t-loading size="small" />
|
||||
<span>{{ $t('auth.workspaceOnboarding.loadingPolicy') }}</span>
|
||||
</div>
|
||||
<div v-else-if="policyLoadFailed" class="policy-error" role="alert">
|
||||
<t-icon name="error-circle" size="20px" aria-hidden="true" />
|
||||
<span>{{ $t('auth.workspaceOnboarding.policyLoadFailed') }}</span>
|
||||
<t-button size="small" variant="text" @click="loadPolicy">
|
||||
{{ $t('auth.workspaceOnboarding.retry') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div v-if="!authStore.canCreateTenant" class="invite-only-notice">
|
||||
<t-icon name="lock-on" size="20px" aria-hidden="true" />
|
||||
<span>{{ $t('auth.workspaceOnboarding.inviteOnlyNotice') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="workspace-actions" :class="{ 'workspace-actions--single': !authStore.canCreateTenant }">
|
||||
<t-button v-if="authStore.canCreateTenant" theme="primary" size="large" @click="createVisible = true">
|
||||
<template #icon><t-icon name="add" /></template>
|
||||
{{ $t('auth.workspaceOnboarding.create') }}
|
||||
</t-button>
|
||||
<t-button
|
||||
:theme="authStore.canCreateTenant ? 'default' : 'primary'"
|
||||
:variant="authStore.canCreateTenant ? 'outline' : 'base'"
|
||||
size="large"
|
||||
@click="invitationsVisible = true"
|
||||
>
|
||||
<template #icon><t-icon name="mail" /></template>
|
||||
{{ $t('auth.workspaceOnboarding.invitations') }}
|
||||
<template v-if="authStore.pendingInvitationCount > 0">
|
||||
({{ authStore.pendingInvitationCount }})
|
||||
</template>
|
||||
</t-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<p v-if="!policyLoading && !policyLoadFailed" class="workspace-help">
|
||||
{{
|
||||
$t(
|
||||
authStore.canCreateTenant
|
||||
? 'auth.workspaceOnboarding.help'
|
||||
: 'auth.workspaceOnboarding.inviteOnlyHelp',
|
||||
)
|
||||
}}
|
||||
</p>
|
||||
<button class="logout-link" type="button" @click="handleLogout">
|
||||
{{ $t('auth.logout') }}
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<CreateTenantDialog v-model:visible="createVisible" @created="onTenantCreated" />
|
||||
<MyInvitationsDialog v-model:visible="invitationsVisible" />
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import CreateTenantDialog from '@/components/CreateTenantDialog.vue'
|
||||
import MyInvitationsDialog from '@/components/MyInvitationsDialog.vue'
|
||||
import { logout as logoutApi } from '@/api/auth'
|
||||
import type { TenantInfo } from '@/api/tenant'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
const router = useRouter()
|
||||
const authStore = useAuthStore()
|
||||
const createVisible = ref(false)
|
||||
const invitationsVisible = ref(false)
|
||||
const policyLoading = ref(true)
|
||||
const policyLoadFailed = ref(false)
|
||||
|
||||
async function loadPolicy() {
|
||||
policyLoading.value = true
|
||||
policyLoadFailed.value = false
|
||||
try {
|
||||
const refreshed = await authStore.refreshFromAuthMe()
|
||||
if (!refreshed) {
|
||||
policyLoadFailed.value = true
|
||||
return
|
||||
}
|
||||
await authStore.fetchPendingInvitationCount()
|
||||
} finally {
|
||||
policyLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadPolicy()
|
||||
})
|
||||
|
||||
watch(
|
||||
() => authStore.hasValidTenant,
|
||||
(ready) => {
|
||||
if (ready) router.replace('/platform/knowledge-bases')
|
||||
},
|
||||
)
|
||||
|
||||
async function onTenantCreated(tenant: TenantInfo) {
|
||||
await authStore.refreshFromAuthMe()
|
||||
authStore.setSelectedTenant(tenant.id, tenant.name)
|
||||
await router.replace('/platform/knowledge-bases')
|
||||
}
|
||||
|
||||
async function handleLogout() {
|
||||
await logoutApi()
|
||||
authStore.logout()
|
||||
await router.replace('/login')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.workspace-onboarding {
|
||||
min-height: 100vh;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 32px 20px;
|
||||
background:
|
||||
radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--td-brand-color) 12%, transparent), transparent 38%),
|
||||
var(--td-bg-color-page);
|
||||
}
|
||||
|
||||
.workspace-card {
|
||||
width: min(520px, 100%);
|
||||
padding: 44px;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 20px;
|
||||
background: var(--td-bg-color-container);
|
||||
box-shadow: var(--td-shadow-2);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.workspace-mark {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
margin: 0 auto 22px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 18px;
|
||||
color: var(--td-brand-color);
|
||||
background: var(--td-brand-color-light);
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
color: var(--td-text-color-primary);
|
||||
font-size: 26px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.workspace-description,
|
||||
.workspace-help {
|
||||
color: var(--td-text-color-secondary);
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.workspace-description {
|
||||
margin: 14px 0 28px;
|
||||
}
|
||||
|
||||
.workspace-actions {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.workspace-actions--single {
|
||||
grid-template-columns: minmax(220px, 1fr);
|
||||
}
|
||||
|
||||
.policy-loading,
|
||||
.invite-only-notice,
|
||||
.policy-error {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
min-height: 52px;
|
||||
margin-bottom: 18px;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.policy-error {
|
||||
flex-wrap: wrap;
|
||||
padding: 12px 16px;
|
||||
border-radius: 10px;
|
||||
color: var(--td-error-color);
|
||||
background: var(--td-error-color-light);
|
||||
}
|
||||
|
||||
.invite-only-notice {
|
||||
padding: 12px 16px;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 10px;
|
||||
color: var(--td-text-color-primary);
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.invite-only-notice :deep(.t-icon) {
|
||||
flex: 0 0 auto;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.workspace-help {
|
||||
margin: 24px 0 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.logout-link {
|
||||
border: 0;
|
||||
padding: 6px 10px;
|
||||
color: var(--td-text-color-secondary);
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.logout-link:hover {
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
|
||||
@media (max-width: 560px) {
|
||||
.workspace-card {
|
||||
padding: 32px 22px;
|
||||
}
|
||||
|
||||
.workspace-actions {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user