great-crayon-86888
02/05/2024, 12:47 PMchilly-king-10285
02/05/2024, 12:47 PMchilly-king-10285
02/05/2024, 12:48 PMtsx import { Configuration, FrontendApi, RecoveryFlow, UiNode, UiNodeInputAttributes, } from "@ory/client" import { filterNodesByGroups, isUiNodeInputAttributes, } from "@ory/integrations/ui" import { useEffect, useState } from "react" import { useSearchParams } from "react-router-dom" const frontend = new FrontendApi( new Configuration({ basePath: "<http://localhost:4000>", // Use your local Ory Tunnel URL baseOptions: { withCredentials: true, // we need to include cookies }, }), ) export const Recovery = () => { const [flow, setFlow] = useState<RecoveryFlow>() const [searchParams] = useSearchParams() useEffect(() => { // we can redirect the user back to the page they were on before login const returnTo = searchParams.get("return_to") frontend .createBrowserRecoveryFlow({ returnTo: returnTo || "/", // redirect to the root path after login }) .then(({ data: flow }) => { // set the flow data setFlow(flow) }) .catch((err) => { // Couldn't create login flow // handle the error }) }, [])
Please note that the account recovery flow doesn't reset the user's second authentication factor. For more details, you can refer to the following documentation: - [Account recovery and password reset](https://www.ory.sh/docs/kratos/self-service/flows/account-recovery-password-reset) - [Recovery flow in custom UI integration](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration#recovery) - [Administrative account recovery](https://www.ory.sh/docs/kratos/manage-identities/account-recovery)great-crayon-86888
02/06/2024, 7:55 AMchilly-king-10285
02/06/2024, 7:55 AMchilly-king-10285
02/06/2024, 7:55 AMreturn_to
URL. 2. An email is sent with a link
or code
method. 3. The user completes the recovery flow by submitting the code
or clicking the link
. 4. The user gets a session and is redirected through the settings
flow. 5. The user submits the settings
flow with an updated password. 6. The user is redirected to the return_to
URL. This process ensures that the user is authenticated and authorized to change the password, providing an additional layer of security. For more details, you can refer to the [Advanced redirects](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-advanced-integration#advanced-redirects) section in the Ory Kratos documentation.