@@ -2,31 +2,17 @@ import { createContext, useState, useEffect, ReactNode, use } from 'react';
22import { MeResponseSchema } from './auth.schemas' ;
33import { AUTH_FLOW_SESSION_KEY } from '../../../common/auth/AuthCallbackHandler.tsx' ;
44import { getRedirectSuffix } from '../../../common/auth/getRedirectSuffix.ts' ;
5- import { RoleBinding } from '../../../lib/api/types/crate/controlPlanes.ts' ;
6- import { useAuthOnboarding } from '../../onboarding/auth/AuthContextOnboarding.tsx' ;
75
86interface AuthContextMcpType {
97 isLoading : boolean ;
108 isAuthenticated : boolean ;
119 error : Error | null ;
1210 login : ( ) => void ;
13- hasMCPAdminRights : boolean ;
1411}
1512
1613const AuthContextMcp = createContext < AuthContextMcpType | null > ( null ) ;
1714
18- export function AuthProviderMcp ( { children, mcpUsers = [ ] } : { children : ReactNode ; mcpUsers ?: RoleBinding [ ] } ) {
19- const auth = useAuthOnboarding ( ) ;
20-
21- const userEmail = auth . user ?. email ;
22-
23- const matchingRoleBinding = mcpUsers . find (
24- ( roleBinding ) =>
25- Array . isArray ( roleBinding . subjects ) &&
26- roleBinding . subjects . some ( ( subject ) => subject ?. name ?. includes ( userEmail ?? '' ) ) ,
27- ) ;
28- const hasMCPAdminRights = matchingRoleBinding ?. role === 'admin' ;
29-
15+ export function AuthProviderMcp ( { children } : { children : ReactNode } ) {
3016 const [ isAuthenticated , setIsAuthenticated ] = useState ( false ) ;
3117 const [ isLoading , setIsLoading ] = useState ( true ) ;
3218 const [ error , setError ] = useState < Error | null > ( null ) ;
@@ -73,9 +59,7 @@ export function AuthProviderMcp({ children, mcpUsers = [] }: { children: ReactNo
7359 window . location . replace ( `/api/auth/mcp/login?redirectTo=${ encodeURIComponent ( getRedirectSuffix ( ) ) } ` ) ;
7460 } ;
7561
76- return (
77- < AuthContextMcp value = { { isLoading, isAuthenticated, error, login, hasMCPAdminRights } } > { children } </ AuthContextMcp >
78- ) ;
62+ return < AuthContextMcp value = { { isLoading, isAuthenticated, error, login } } > { children } </ AuthContextMcp > ;
7963}
8064
8165export const useAuthMcp = ( ) => {
0 commit comments