Completing login process...
- ) -} - -function constructOauthRedirectApiServerUrl(pathToApiServerRouteHandlingOauthRedirect) { - // Take the redirect query params supplied by the external OAuth provider and - // send them as-is to our backend, so Passport can finish the process. - const queryParams = window.location.search - return `${config.apiUrl}${pathToApiServerRouteHandlingOauthRedirect}${queryParams}` -} - -async function exchangeCodeForSessionIdAndRedirect(history, apiServerUrlHandlingOauthRedirect) { - const sessionId = await exchangeCodeForSessionId(apiServerUrlHandlingOauthRedirect) - - if (sessionId !== null) { - await initSession(sessionId) - history.push('{= onAuthSucceededRedirectTo =}') - } else { - console.error('Error obtaining session ID') - history.push('{= onAuthFailedRedirectTo =}') - } -} - -async function exchangeCodeForSessionId(url) { - try { - const response = await api.get(url) - return response?.data?.sessionId || null - } catch (e) { - console.error(e) - return null - } -} diff --git a/waspc/data/Generator/templates/react-app/src/router.tsx b/waspc/data/Generator/templates/react-app/src/router.tsx index 1113b1e6f1..5234bbd786 100644 --- a/waspc/data/Generator/templates/react-app/src/router.tsx +++ b/waspc/data/Generator/templates/react-app/src/router.tsx @@ -14,7 +14,7 @@ import createAuthRequiredPage from "./auth/pages/createAuthRequiredPage" {=/ pagesToImport =} {=# isExternalAuthEnabled =} -import OAuthCodeExchange from "./auth/pages/OAuthCodeExchange" +import { OAuthCallbackPage } from "./auth/pages/OAuthCallback" {=/ isExternalAuthEnabled =} import { routes } from 'wasp/client/router' @@ -40,13 +40,9 @@ const router = ( /> ))} {=# isExternalAuthEnabled =} - {=# externalAuthProviders =} - {=# authProviderEnabled =} -Completing login process...
- ) -} - -function constructOauthRedirectApiServerUrl(pathToApiServerRouteHandlingOauthRedirect) { - // Take the redirect query params supplied by the external OAuth provider and - // send them as-is to our backend, so Passport can finish the process. - const queryParams = window.location.search - return `${config.apiUrl}${pathToApiServerRouteHandlingOauthRedirect}${queryParams}` -} - -async function exchangeCodeForSessionIdAndRedirect(history, apiServerUrlHandlingOauthRedirect) { - const sessionId = await exchangeCodeForSessionId(apiServerUrlHandlingOauthRedirect) - - if (sessionId !== null) { - await initSession(sessionId) - history.push('/') - } else { - console.error('Error obtaining session ID') - history.push('/login') - } -} - -async function exchangeCodeForSessionId(url) { - try { - const response = await api.get(url) - return response?.data?.sessionId || null - } catch (e) { - console.error(e) - return null - } -} diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/src/router.tsx b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/src/router.tsx index 2170647a5f..7ced466397 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/src/router.tsx +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/src/router.tsx @@ -6,7 +6,7 @@ import createAuthRequiredPage from "./auth/pages/createAuthRequiredPage" import { MainPage } from '../../../../src/MainPage' -import OAuthCodeExchange from "./auth/pages/OAuthCodeExchange" +import { OAuthCallbackPage } from "./auth/pages/OAuthCallback" import { routes } from 'wasp/client/router' @@ -26,8 +26,8 @@ const router = ( component={routeNameToRouteComponent[routeKey]} /> ))} -