Skip to content

Commit

Permalink
feat: experiment with forceRefresh to use in impersonation
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed Dec 17, 2024
1 parent bfe9f61 commit 8c139ec
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 54 deletions.
101 changes: 58 additions & 43 deletions lib/build/oauth2providerprebuiltui.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
import * as React from "react";
import { useContext, Fragment } from "react";

import { redirectToAuth } from "../../../../..";
import FeatureWrapper from "../../../../../components/featureWrapper";
import SuperTokens from "../../../../../superTokens";
import { useUserContext } from "../../../../../usercontext";
import { getQueryParams, getTenantIdFromQueryParams, useRethrowInRender } from "../../../../../utils";
import DynamicLoginMethodsSpinner from "../../../../multitenancy/components/features/dynamicLoginMethodsSpinner";
import { SessionContext } from "../../../../session";
import { SessionContext, attemptRefreshingSession } from "../../../../session";
import { defaultTranslationsOAuth2Provider } from "../../themes/translations";

import type { FeatureBaseProps, UserContext } from "../../../../../types";
Expand All @@ -41,15 +42,19 @@ export const TryRefreshPage: React.FC<Prop> = (props) => {
const rethrowInRender = useRethrowInRender();
const sessionContext = useContext(SessionContext);
const loginChallenge = getQueryParams("loginChallenge") ?? undefined;
const forceRefresh = getQueryParams("forceRefresh") ?? undefined;
let userContext = useUserContext();
if (props.userContext !== undefined) {
userContext = props.userContext;
}

React.useEffect(() => {
if (sessionContext.loading === false) {
if (loginChallenge) {
(async function () {
(async function () {
if (forceRefresh) {
await attemptRefreshingSession();
}
if (loginChallenge) {
const { frontendRedirectTo } = await props.recipe.webJSRecipe.getRedirectURLToContinueOAuthFlow({
loginChallenge,
userContext,
Expand All @@ -65,15 +70,13 @@ export const TryRefreshPage: React.FC<Prop> = (props) => {
{},
userContext
);
})().catch(rethrowInRender);
} else {
void SuperTokens.getInstanceOrThrow()
.redirectToAuth({
userContext,
} else {
await redirectToAuth({
redirectBack: false,
})
.catch(rethrowInRender);
}
userContext,
});
}
})().catch(rethrowInRender);
}
}, [loginChallenge, props.recipe, props.navigate, userContext, sessionContext]);

Expand Down

0 comments on commit 8c139ec

Please sign in to comment.