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

Added encoded redirect uri to path

jnfrati 4 лет назад
Родитель
Сommit
b115a8a4d2

+ 6 - 1
dashboard/src/main/home/onboarding/steps/ConnectRegistry/forms/_DORegistryForm.tsx

@@ -4,6 +4,7 @@ import SaveButton from "components/SaveButton";
 import { OFState } from "main/home/onboarding/state";
 import { DORegistryConfig } from "main/home/onboarding/types";
 import React, { useEffect, useState } from "react";
+import { useLocation } from "react-router";
 import api from "shared/api";
 import styled from "styled-components";
 import { useSnapshot } from "valtio";
@@ -20,6 +21,7 @@ export const CredentialsForm: React.FC<{
   nextFormStep: (data: Partial<DORegistryConfig>) => void;
   project: any;
 }> = ({ nextFormStep, project }) => {
+  const location = useLocation();
   useEffect(() => {
     api.getOAuthIds("<token>", {}, { project_id: project?.id }).then((res) => {
       let tgtIntegration = res.data.find((integration: any) => {
@@ -36,11 +38,14 @@ export const CredentialsForm: React.FC<{
     });
   }, []);
 
+  const url = `${window.location.protocol}//${window.location.host}${window.location.pathname}`;
+
+  const encoded_redirect_uri = encodeURIComponent(url);
   return (
     <>
       <ConnectDigitalOceanButton
         target={"_blank"}
-        href={`/api/projects/${project?.id}/oauth/digitalocean`}
+        href={`/api/projects/${project?.id}/oauth/digitalocean?redirect_uri=${encoded_redirect_uri}`}
       >
         Connect Digital Ocean
       </ConnectDigitalOceanButton>

+ 7 - 1
dashboard/src/main/home/onboarding/steps/ConnectSource.tsx

@@ -62,6 +62,10 @@ const ConnectSource: React.FC<{
     onSuccess(selectedSource);
   };
 
+  const url = `${window.location.protocol}//${window.location.host}${window.location.pathname}`;
+
+  const encoded_redirect_uri = encodeURIComponent(url);
+
   return (
     <>
       <TitleSection>Getting Started</TitleSection>
@@ -72,7 +76,9 @@ const ConnectSource: React.FC<{
       </Helper>
       {!isLoading && (!accountData || !accountData?.accounts?.length) && (
         <>
-          <ConnectToGithubButton href="/api/integrations/github-app/oauth">
+          <ConnectToGithubButton
+            href={`/api/integrations/github-app/install?redirect_uri=${encoded_redirect_uri}`}
+          >
             Connect to github
           </ConnectToGithubButton>
           <Helper>