Skip to content

Commit d07be6b

Browse files
obdevob-robot
authored andcommitted
PullRequest: 504 feat: implement password-free login handling in layout component
1 parent 0400acc commit d07be6b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

frontend/src/page/Layout/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ interface LayoutProps {
3737

3838
const Layout: React.FC<LayoutProps> = ({ children, location }) => {
3939
const { themeMode } = useSelector((state: DefaultRootState) => state.global);
40+
const { query } = location;
41+
const { mode } = query || {};
42+
const isPasswordFreeLogin = mode === 'passwordFreeLogin';
4043

4144
const locale = getLocale();
4245
const localeMap = {
@@ -77,7 +80,10 @@ const Layout: React.FC<LayoutProps> = ({ children, location }) => {
7780
HIDE_ERROR_MESSAGE: true,
7881
}),
7982
{
80-
ready: isTelemetryOutdated && !loading,
83+
ready:
84+
isTelemetryOutdated &&
85+
// 如果是免密登录场景,获取到 secret 后在进行 statistics 请求,避免 401 错误
86+
(isPasswordFreeLogin ? !loading : true),
8187
// 一小时 + 5秒 轮训一次。5s 是为了避免请求 telemetry 接口时 ,时间差(telemetryTime 判断)导致的请求失败
8288
pollingInterval: 1000 * 60 * 60 + 5000,
8389
onSuccess: res => {
@@ -120,8 +126,8 @@ const Layout: React.FC<LayoutProps> = ({ children, location }) => {
120126
}, []);
121127

122128
// 登录页不需要 publicKey loading
123-
if (loading && location?.pathname !== '/login') {
124-
// publicKey 获取之后再加载内容,空密码场景下只需要 publicKey 即可登录,不需要获取密码
129+
if (isPasswordFreeLogin && loading && location?.pathname !== '/login') {
130+
// publicKey 获取之后再加载内容,空密码场景下只需要 publicKey 即可登录(实现免密登录),无须获取密码
125131
return <Spin style={{ marginTop: '20vh' }}></Spin>;
126132
}
127133

0 commit comments

Comments
 (0)