MCPcopy Create free account
hub / github.com/ShipSecAI/studio / useAuthProviderSync

Function useAuthProviderSync

frontend/src/auth/store-integration.ts:103–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

101 * This ensures the frontend and backend are using the same auth provider
102 */
103export function useAuthProviderSync() {
104 const { provider: storeProvider } = useAuthStore();
105 const authProvider = useAuthProvider();
106 const providerForStore = resolvedProviderForReturn(authProvider.name);
107
108 useEffect(() => {
109 // Check if frontend and backend auth providers are aligned
110 const configuredFrontendProvider = (import.meta.env.VITE_AUTH_PROVIDER ||
111 providerForStore) as string;
112 const backendProvider = import.meta.env.VITE_API_AUTH_PROVIDER || configuredFrontendProvider;
113
114 if (configuredFrontendProvider !== backendProvider) {
115 console.warn(
116 `Auth provider mismatch: frontend=${configuredFrontendProvider}, backend=${backendProvider}. ` +
117 'This may cause authentication issues.',
118 );
119 }
120
121 // Update store provider if needed
122 if (storeProvider !== providerForStore) {
123 useAuthStore.getState().setProvider(providerForStore);
124 }
125 }, [providerForStore, storeProvider]);
126
127 return {
128 provider: resolvedProviderForReturn(authProvider.name),
129 };
130}
131
132function resolvedProviderForReturn(name: string): 'local' | 'clerk' | 'custom' {
133 if (name === 'clerk') {

Callers

nothing calls this directly

Calls 3

useAuthProviderFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected