diff --git a/src/components/Authentication/Kratos/KratosLogin.tsx b/src/components/Authentication/Kratos/KratosLogin.tsx index 4102f281c8..f7a687d916 100644 --- a/src/components/Authentication/Kratos/KratosLogin.tsx +++ b/src/components/Authentication/Kratos/KratosLogin.tsx @@ -54,7 +54,7 @@ const Login: NextPage = () => { }) .then(({ data }) => { setFlow(data); - SetUriFlow(Router, data.id); + SetUriFlow(Router, data.id, returnTo); }) .catch(handleError), [handleError] diff --git a/src/components/ory/helpers.ts b/src/components/ory/helpers.ts index 035c2258a0..88211cf9b8 100644 --- a/src/components/ory/helpers.ts +++ b/src/components/ory/helpers.ts @@ -3,11 +3,24 @@ import { NextRouter } from "next/router"; -export const SetUriFlow = (router: NextRouter, id: string) => { +export const SetUriFlow = ( + router: NextRouter, + id: string, + returnTo: string +) => { // Check that current query flow id does not match requested one - pushing will trigger useEffect if router bound if (router.query.flow === id) { return; } - router.push(`${router.pathname}?flow=${id}`, undefined, { shallow: true }); + router.push( + `${router.pathname}`, + { + query: { + return_to: returnTo, + flow: id + } + }, + { shallow: true } + ); }; diff --git a/src/components/ory/hooks.ts b/src/components/ory/hooks.ts index 643f5f6a29..4dc1f3f6f3 100644 --- a/src/components/ory/hooks.ts +++ b/src/components/ory/hooks.ts @@ -173,12 +173,10 @@ export function useCreateLogoutHandler(deps?: DependencyList) { const handleError = HandleError(); const { push } = useRouter(); - const returnTo = useMemo(() => { - if (typeof window !== "undefined") { - return window.location.pathname + window.location.search; - } - return undefined; - }, []); + const returnTo = + typeof window !== "undefined" + ? window.location.pathname + window.location.search + : undefined; useEffect(() => { ory diff --git a/src/components/ory/ui/Flow.tsx b/src/components/ory/ui/Flow.tsx index 4fb8cafbf0..e1e7f738d4 100644 --- a/src/components/ory/ui/Flow.tsx +++ b/src/components/ory/ui/Flow.tsx @@ -201,42 +201,40 @@ export class Flow extends Component, State> { /> ); })} +
+
+ {filterNodesByGroups({ + nodes: nodes, + groups: ["oidc", "webauthn"], + withoutDefaultGroup: true + }).map((node, k) => { + const id = getNodeId(node) as keyof Values; + return ( + + new Promise((resolve) => { + this.setState( + (state) => ({ + ...state, + values: { + ...state.values, + [getNodeId(node)]: value + } + }), + resolve + ); + }) + } + /> + ); + })} +
- -
- -
- {filterNodesByGroups({ - nodes: nodes, - groups: ["oidc", "webauthn"], - withoutDefaultGroup: true - }).map((node, k) => { - const id = getNodeId(node) as keyof Values; - return ( - - new Promise((resolve) => { - this.setState( - (state) => ({ - ...state, - values: { - ...state.values, - [getNodeId(node)]: value - } - }), - resolve - ); - }) - } - /> - ); - })} -
); }