-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9acdfc
commit 76d6f48
Showing
9 changed files
with
157 additions
and
32 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import config from "@/ory.config" | ||
import { getSettingsFlow, OryPageParams } from "@ory/nextjs/app" | ||
import { SessionProvider } from "../../../packages/elements-react/dist/client/session-provider" | ||
import { Settings } from "@ory/elements-react/theme" | ||
import { enhanceOryConfig } from "@ory/nextjs" | ||
import { useSettingsFlow } from "@ory/nextjs/pages" | ||
|
||
export default function SettingsPage() { | ||
const flow = useSettingsFlow() | ||
|
||
if (!flow) { | ||
return null | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col gap-8 items-center mb-8"> | ||
<SessionProvider> | ||
<Settings | ||
flow={flow} | ||
config={enhanceOryConfig(config)} | ||
components={{ | ||
Card: {}, | ||
}} | ||
/> | ||
</SessionProvider> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { LogoutFlow } from "@ory/client-fetch" | ||
import { clientSideFrontendClient } from "./client" | ||
import { useEffect, useState } from "react" | ||
|
||
export function useLogoutFlow() { | ||
const [flow, setFlow] = useState<LogoutFlow | undefined>(undefined) | ||
|
||
const createFlow = async () => { | ||
const flow = await clientSideFrontendClient().createBrowserLogoutFlow({}) | ||
setFlow(flow) | ||
} | ||
|
||
useEffect(() => { | ||
if (!flow) { | ||
void createFlow() | ||
} | ||
}, []) | ||
|
||
return flow | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { FlowType } from "@ory/client-fetch" | ||
import { createUseFlowFactory } from "./flow" | ||
import { clientSideFrontendClient } from "./client" | ||
|
||
export const useSettingsFlow = createUseFlowFactory( | ||
FlowType.Settings, | ||
(params: URLSearchParams) => { | ||
return clientSideFrontendClient().createBrowserSettingsFlowRaw({ | ||
returnTo: params.get("return_to") ?? undefined, | ||
cookie: params.get("cookie") ?? undefined, | ||
}) | ||
}, | ||
(id) => clientSideFrontendClient().getSettingsFlowRaw({ id }), | ||
) |