Don't set config from OAuth callbacks until after it has been loaded

This commit is contained in:
Alex Gleason committed 2025-10-18 22:08:58 -05:00
1 parent fcc5d26faa
commit bfe8d76db4
11 files changed
+49 -194

No files matched your search

+7 -2
View File
@@ -17,7 +17,7 @@ interface NetlifyUserInfo {
* Uses the generic useOAuth hook with Netlify-specific configuration.
*/
export function useNetlifyOAuth() {
const { setProviders, settings } = useDeploySettings();
const { setProviders, settings, isInitialized } = useDeploySettings();
// Netlify OAuth configuration
const config: OAuthConfig = {
@@ -58,6 +58,11 @@ export function useNetlifyOAuth() {
code: string,
state: string
): Promise<boolean> => {
// Wait for settings to be initialized before processing
if (!isInitialized) {
return false;
}
const result: OAuthResult | null = await oauth.handleCallback(code, state);
if (!result) {
@@ -78,7 +83,7 @@ export function useNetlifyOAuth() {
setProviders([...settings.providers, newProvider]);
return true;
}, [oauth, setProviders, settings.providers]);
}, [oauth, setProviders, settings.providers, isInitialized]);
return {
...oauth,