refactor(auth): unify OIDC provisioning under shared default_tenant_mode policy
Drop the standalone OIDC_AUTH_DEFAULT_TENANT_MODE / oidc_auth.default_tenant_mode knob so OIDC auto-provisioning and local password registration share the single auth.default_tenant_mode policy (resolved by the callback handler). Repair tenantless sessions by falling back to the first active membership on the login happy path and stale-preference paths, allow tenantless PUT /auth/me/preferences, clear the tenant snapshot on /auth/me responses without a tenant, and default the frontend canCreateTenant capability to fail-closed until /auth/me confirms it.
This commit is contained in:
@@ -556,7 +556,8 @@ const loadUserInfo = async () => {
|
||||
// (同时污染 localStorage),系统管理入口在 hover 工作空间触发
|
||||
// refreshFromAuthMe 后才出现。新增字段请只改 userInfoFromApi。
|
||||
authStore.setUser(userInfoFromApi(user))
|
||||
// 如果返回了租户信息,也更新租户信息
|
||||
// 如果返回了租户信息,也更新租户信息;tenantless 用户(/auth/me
|
||||
// 无 tenant)必须显式清空,否则会残留上一账号/上一会话的租户快照。
|
||||
if (response.data.tenant) {
|
||||
authStore.setTenant({
|
||||
id: String(response.data.tenant.id),
|
||||
@@ -565,6 +566,8 @@ const loadUserInfo = async () => {
|
||||
created_at: response.data.tenant.created_at,
|
||||
updated_at: response.data.tenant.updated_at
|
||||
})
|
||||
} else {
|
||||
authStore.setTenant(null)
|
||||
}
|
||||
const membershipsSync = response.data.memberships
|
||||
if (Array.isArray(membershipsSync)) {
|
||||
|
||||
@@ -53,8 +53,11 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
// 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)
|
||||
// false (fail-closed): we hide the "create workspace" affordance until
|
||||
// /auth/me confirms the deployment allows it, so an invitation-only
|
||||
// deployment never briefly flashes a create action the backend would
|
||||
// then reject with 403/2005.
|
||||
const canCreateTenant = ref(false)
|
||||
|
||||
// 计算属性
|
||||
const isLoggedIn = computed(() => {
|
||||
@@ -408,7 +411,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
allTenants.value = []
|
||||
memberships.value = []
|
||||
pendingInvitationCount.value = 0
|
||||
canCreateTenant.value = true
|
||||
canCreateTenant.value = false
|
||||
clearSessionResourceCaches()
|
||||
|
||||
// 清空localStorage
|
||||
|
||||
Reference in New Issue
Block a user