Просмотр исходного кода

fix: merge

fix: oauth授权跳转
hear 3 лет назад
Родитель
Сommit
1f00550b98
2 измененных файлов с 13 добавлено и 11 удалено
  1. 2 2
      src/pages/iframe/index.tsx
  2. 11 9
      src/pages/oauth/index.tsx

+ 2 - 2
src/pages/iframe/index.tsx

@@ -11,7 +11,7 @@ const Iframe = () => {
     const res = await service.detail(appId);
     let menuUrl: any = url;
     if (res.status === 200) {
-      console.log(res.result);
+      // console.log(res.result);
       if (res.result.page.routeType === 'hash') {
         menuUrl = `${url}`;
       }
@@ -19,7 +19,7 @@ const Iframe = () => {
         //{baseUrl}/api/application/sso/{appId}/login?redirect={menuUrl}
         const urlStandalone = `${res.result.page.baseUrl}/api/application/sso/${appId}/login?redirect=${menuUrl}?layout=false`;
         setIframeUrl(urlStandalone);
-        console.log(urlStandalone);
+        // console.log(urlStandalone);
       } else {
         const urlOther = `${res.result.page.baseUrl}/${menuUrl}`;
         setIframeUrl(urlOther);

+ 11 - 9
src/pages/oauth/index.tsx

@@ -119,26 +119,26 @@ const Oauth = () => {
     },
   };
 
-  const initApplication = async () => {
-    const res: any = await Service.initApplication(params.client_id);
+  const initApplication = async (cilentId: string) => {
+    const res: any = await Service.initApplication(cilentId);
     if (res.status === 200) {
       setAppName(res.result?.name);
     }
   };
 
-  const getLoginUser = async () => {
+  const getLoginUser = async (data?: any) => {
     const res = await Service.queryCurrent();
     if (res && res.status === 200) {
       setUerName(res.result.user.name);
       setIsLogin(true);
-      initApplication();
-      if (internal === 'true') {
+      initApplication(data.client_id || params.client_id);
+      if (data.internal === 'true' || internal === 'true') {
         goOAuth2();
       }
     } else if (res.status === 401) {
       setIsLogin(false);
       getCode();
-      initApplication();
+      initApplication(data.client_id || params.client_id);
     } else {
       setIsLogin(false);
     }
@@ -176,7 +176,6 @@ const Oauth = () => {
   useEffect(() => {
     document.title = 'OAuth授权-jetlinks';
     getCode();
-    getLoginUser();
   }, []);
 
   useEffect(() => {
@@ -189,10 +188,13 @@ const Oauth = () => {
       scope: getQueryVariable('scope'),
     };
     const item = getQueryVariable('internal');
+    getLoginUser({
+      ...items,
+      internal: getQueryVariable('internal'),
+    });
     setLinternal(item);
     setParams(items);
-    console.log(items);
-    console.log(window.location);
+    console.log(item, items, 'oauth');
   }, [window.location]);
 
   //未登录状态