From febaef9cf97ab0ecf17d56aa971cc3fd61c36ca7 Mon Sep 17 00:00:00 2001 From: YANG QIA <2013xile@gmail.com> Date: Mon, 31 Mar 2025 12:53:25 +0800 Subject: [PATCH] fix(auth): token assignment in `AuthProvider` (#6593) --- .../plugin-auth/src/client/AuthProvider.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-auth/src/client/AuthProvider.tsx b/packages/plugins/@nocobase/plugin-auth/src/client/AuthProvider.tsx index 9f88e94e0e..85ab4b286c 100644 --- a/packages/plugins/@nocobase/plugin-auth/src/client/AuthProvider.tsx +++ b/packages/plugins/@nocobase/plugin-auth/src/client/AuthProvider.tsx @@ -13,15 +13,13 @@ import React, { useEffect } from 'react'; export const AuthProvider: React.FC = (props) => { const searchString = useLocationSearch(); const app = useApp(); + const params = new URLSearchParams(searchString); + const authenticator = params.get('authenticator'); + const token = params.get('token'); + if (token) { + app.apiClient.auth.setToken(token); + app.apiClient.auth.setAuthenticator(authenticator); + } - useEffect(() => { - const params = new URLSearchParams(searchString); - const authenticator = params.get('authenticator'); - const token = params.get('token'); - if (token) { - app.apiClient.auth.setToken(token); - app.apiClient.auth.setAuthenticator(authenticator); - } - }); return <>{props.children}; };