1- import {
2- createContext ,
3- ReactNode ,
4- useContext ,
5- useEffect ,
6- useState ,
7- } from 'react' ;
1+ import { createContext , ReactNode , useContext } from 'react' ;
82import { ControlPlane as ManagedControlPlaneResource } from '../api/types/crate/controlPlanes.ts' ;
93import { GetAuthPropsForContextName } from '../oidc/shared.ts' ;
10- import { AuthProvider , hasAuthParams , useAuth } from 'react-oidc-context' ;
4+ import { AuthProvider } from 'react-oidc-context' ;
115import {
126 ApiConfigContext ,
137 ApiConfigProvider ,
@@ -66,29 +60,9 @@ export const McpContextProvider = ({ children, context }: Props) => {
6660} ;
6761
6862function RequireDownstreamLogin ( props : { children ?: ReactNode } ) {
69- const auth = useAuth ( ) ;
7063 const mcp = useContext ( McpContext ) ;
71- const [ hasTriedSignin , setHasTriedSignin ] = useState ( false ) ;
7264 const parentApiConfig = useContext ( ApiConfigContext ) ;
7365
74- // automatically sign-in
75- useEffect ( ( ) => {
76- if (
77- ! hasAuthParams ( ) &&
78- ! auth . isAuthenticated &&
79- ! auth . activeNavigator &&
80- ! auth . isLoading &&
81- ! hasTriedSignin
82- ) {
83- auth . signinPopup ( ) . then ( ( _ ) => {
84- setHasTriedSignin ( true ) ;
85- } ) ;
86- }
87- } , [ auth , hasTriedSignin ] ) ;
88-
89- if ( ! auth . isAuthenticated || auth . isLoading ) {
90- return < > Elevating your permissions</ > ;
91- }
9266 return (
9367 < >
9468 < ApiConfigProvider
@@ -100,7 +74,6 @@ function RequireDownstreamLogin(props: { children?: ReactNode }) {
10074 projectName : mcp . project ,
10175 workspaceName : mcp . workspace ,
10276 controlPlaneName : mcp . name ,
103- mcpAuthorization : auth . user ?. access_token ?? '' ,
10477 } ,
10578 } }
10679 >
0 commit comments