diff --git a/apps/chat/serializers/chat_user_serializer.py b/apps/chat/serializers/chat_user_serializer.py
index 3fde9f54015..b87979ecffa 100644
--- a/apps/chat/serializers/chat_user_serializer.py
+++ b/apps/chat/serializers/chat_user_serializer.py
@@ -43,7 +43,7 @@ def _get_login_policy(cls, access_token):
)
portal = Portal.objects.first()
if portal is None or not portal.enable_auth:
- raise AppApiException(500, _("Portal authentication is not enabled"))
+ return ("portal", 1, 5, 10)
auth_config = portal.auth_config or {}
if "LOCAL" not in auth_config.get("login_value", ["LOCAL"]):
raise AppApiException(500, _("Portal local login is not enabled"))
diff --git a/ui/src/conversation-panel/left-sidebar/account-menu/index.vue b/ui/src/conversation-panel/left-sidebar/account-menu/index.vue
index 017de839298..278dae3eaa0 100644
--- a/ui/src/conversation-panel/left-sidebar/account-menu/index.vue
+++ b/ui/src/conversation-panel/left-sidebar/account-menu/index.vue
@@ -1,6 +1,6 @@
@@ -101,7 +110,7 @@ const handleLogout = () => {
- 立即登录
+ 立即登录
diff --git a/ui/src/router/ROUTE_README.md b/ui/src/router/ROUTE_README.md
index 34cae91e50a..585a8d86f4a 100644
--- a/ui/src/router/ROUTE_README.md
+++ b/ui/src/router/ROUTE_README.md
@@ -126,8 +126,8 @@ Chat 导航守卫(`chat/index.ts`):
2. 获取目标场景的认证前置配置(`AuthProfile`),与当前场景相同时复用。accessToken 无效、应用已停用或门户
未开放导致获取失败时,进入 `chat-not-found` 并保留原地址;匿名认证失败时同样处理。
3. 判断时只读取目标场景在本地存储中的 token,不切换 Store 的当前场景。
-4. `enable_auth` 为 false 时登录页无用:进入登录页会被重定向到 `redirect` 记录的原地址,没有时进入
- 当前场景首页(`portal-home` 或 `chat-home`),再按下一条匿名认证。
+4. 登录页始终放行:`enable_auth` 为 true 时必须登录;为 false 时匿名用户也可从账户菜单主动登录,
+ 登录成功后回到 `redirect` 记录的原地址。
5. 进入登录页或已有可用 token 时,调用 `auth.activate()` 切换当前场景后放行。`enable_auth` 为 true 时,
匿名认证颁发的 token(载荷 `login_type` 为 `ANNOTATION`,由 `isAnonymousToken` 判断)不可用,
即使本地已保存也跳转登录页;该 token 保留在本地存储,登录时携带。
diff --git a/ui/src/router/chat/index.ts b/ui/src/router/chat/index.ts
index 6cd01df4543..e8f5f5c8a01 100644
--- a/ui/src/router/chat/index.ts
+++ b/ui/src/router/chat/index.ts
@@ -28,13 +28,6 @@ function getLoginRoute(scope: string, to: RouteLocationNormalized) {
return scope === PORTAL_AUTH_SCOPE ? { name: 'portal-login', query } : { name: 'chat-login', params: { accessToken: scope }, query }
}
-/** 未开启认证时登录页无用,回到 `redirect` 记录的原地址,没有时进入当前场景首页。 */
-function getLoginRedirectRoute(scope: string, to: RouteLocationNormalized) {
- const { redirect } = to.query
- if (typeof redirect === 'string' && redirect.startsWith('/')) return { path: redirect, replace: true }
- return scope === PORTAL_AUTH_SCOPE ? { name: 'portal-home', replace: true } : { name: 'chat-home', params: { accessToken: scope }, replace: true }
-}
-
/** 渲染 404 页面并保留原地址,刷新时可重新尝试。 */
function getNotFoundRoute(to: RouteLocationNormalized) {
return { name: 'chat-not-found', params: { pathMatch: to.path.substring(1).split('/') }, query: to.query, hash: to.hash }
@@ -56,8 +49,8 @@ chatRouter.beforeEach(async (to) => {
return getNotFoundRoute(to)
}
+ // 登录页始终放行:开启认证时必须登录,未开启认证时匿名用户也可主动登录
const isLoginRoute = LOGIN_ROUTE_NAMES.has(String(to.name))
- if (isLoginRoute && !authProfile.enable_auth) return getLoginRedirectRoute(scope, to)
// 判断时只读取目标场景已保存的 token,放行前再切换当前场景,避免导航未完成时请求带上目标场景的 token
// 开启认证后,此前保存的匿名 token 不再放行,需要登录;本地存储保留,登录时携带以沿用同一对话用户