-
-
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
393b532
commit d2dea90
Showing
7 changed files
with
79 additions
and
12 deletions.
There are no files selected for viewing
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,46 @@ | ||
"use server" | ||
|
||
import { OryConfig } from "../" | ||
import { newOryProjectClient } from "../sdk" | ||
|
||
const client = newOryProjectClient() | ||
|
||
export async function getProjectConfig(): Promise<OryConfig> { | ||
const list = await client.listProjects().catch((err) => { | ||
throw new Error( | ||
"Unable to fetch the project list, please check your configuration and Ory Project API Key.", | ||
err, | ||
) | ||
}) | ||
|
||
if (list.length > 1) { | ||
console.warn( | ||
"Found more than one project for the configured Ory Project API Key. Using the first one.", | ||
) | ||
} | ||
|
||
if (list.length === 0) { | ||
throw new Error( | ||
"Expected to find one project but found none. Please verify your configuration and check that your Ory Project API Key is valid for only one project.", | ||
) | ||
} | ||
|
||
const project = await client | ||
.getProject({ projectId: list[0].id }) | ||
.catch((err) => { | ||
throw new Error("Unable to fetch the project configuration.") | ||
}) | ||
|
||
const config = project.services.identity?.config as any | ||
return Promise.resolve({ | ||
override: { | ||
applicationName: project.name, | ||
recovery_ui_path: config.selfservice.flows.recovery.ui_url, | ||
registration_ui_path: config.selfservice.flows.registration.ui_url, | ||
login_ui_path: config.selfservice.flows.login.ui_url, | ||
settings_ui_path: config.selfservice.flows.settings.ui_url, | ||
error_ui_path: config.selfservice.flows.error.ui_url, | ||
verification_ui_path: config.selfservice.flows.verification.ui_url, | ||
}, | ||
}) | ||
} |
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { OryConfig } from "./types" | ||
import { useOryConfig } from "./config" | ||
import { useSession } from "./hooks" | ||
import { newFrontendClient } from "./sdk" | ||
import { newOryFrontendClient } from "./sdk" | ||
|
||
export type { OryConfig } | ||
export { useOryConfig, newFrontendClient, useSession } | ||
export { useOryConfig, newOryFrontendClient, useSession } |
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