Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
61b6134a
authored
Jul 03, 2026
by
Finley Ge
Committed by
GitHub
Jul 03, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(chat): show login modal on expired auth (#7246)
parent
3920b6b7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
projects/app/src/pages/chat/index.tsx
+15
-0
projects/app/test/web/common/api/request.test.ts
+18
-0
No files found.
projects/app/src/pages/chat/index.tsx
View file @
61b6134a
...
...
@@ -26,6 +26,8 @@ import { getLogger, LogCategories } from '@fastgpt/service/common/logger';
import
{
PublishChannelEnum
}
from
'@fastgpt/global/support/outLink/constant'
;
import
type
{
LoginSuccessResponseType
}
from
'@fastgpt/global/openapi/support/user/account/login/api'
;
import
type
{
GetPaginationRecordsBodyType
}
from
'@fastgpt/global/openapi/core/chat/record/api'
;
import
{
AUTH_ERROR_EVENT_NAME
}
from
'@/web/common/api/request'
;
import
{
clearToken
}
from
'@/web/support/user/auth'
;
const
logger
=
getLogger
(
LogCategories
.
MODULE
.
CHAT
.
ITEM
);
...
...
@@ -236,6 +238,19 @@ const Render = (props: ChatPageProps) => {
);
useEffect
(()
=>
{
const
handleAuthError
=
()
=>
{
// 全局拦截器已豁免 /chat 跳转;这里同步页面态,触发本页 LoginModal。
setUserInfo
(
null
);
void
clearToken
();
};
window
.
addEventListener
(
AUTH_ERROR_EVENT_NAME
,
handleAuthError
);
return
()
=>
{
window
.
removeEventListener
(
AUTH_ERROR_EVENT_NAME
,
handleAuthError
);
};
},
[
setUserInfo
]);
useEffect
(()
=>
{
if
(
!
props
.
shouldInitUserInfo
)
return
;
let
isUnmounted
=
false
;
...
...
projects/app/test/web/common/api/request.test.ts
View file @
61b6134a
...
...
@@ -176,6 +176,24 @@ describe('request utils', () => {
expect
(
mockLocation
.
replace
).
not
.
toHaveBeenCalled
();
});
it
(
'should dispatch auth error without redirecting on chat page'
,
async
()
=>
{
mockLocation
.
pathname
=
'/test-route/chat'
;
const
err
=
{
response
:
{
data
:
{
code
:
tokenErrorCode
}
}
};
await
expect
(
responseError
(
err
)).
rejects
.
toEqual
({
message
:
'common:unauth_token'
});
expect
(
dispatchEventMock
).
toHaveBeenCalledWith
(
expect
.
any
(
CustomEvent
));
expect
(
dispatchEventMock
.
mock
.
calls
[
0
]?.[
0
].
type
).
toBe
(
AUTH_ERROR_EVENT_NAME
);
expect
(
clearToken
).
not
.
toHaveBeenCalled
();
expect
(
mockLocation
.
replace
).
not
.
toHaveBeenCalled
();
});
it
(
'should handle team error'
,
async
()
=>
{
const
err
=
{
response
:
{
data
:
{
statusText
:
TeamErrEnum
.
aiPointsNotEnough
}
}
};
await
expect
(
responseError
(
err
)).
rejects
.
toEqual
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment