Skip to content

Commit

Permalink
chore: remove ory-prettier-styles
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas committed Aug 30, 2024
1 parent ea84a03 commit 412dc03
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 80 deletions.
5 changes: 2 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"proseWrap": "always",
"singleQuote": true,
"trailingComma": "none",
"parser": "typescript"
"trailingComma": "all",
"semi": false
}
140 changes: 71 additions & 69 deletions examples/nextjs-spa/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,78 +16,80 @@ export const middleware = async (request: NextRequest) =>
!["/", "/settings"].includes(new URL(request.url).pathname)
? NextResponse.next()
: process.env.NEXT_PUBLIC_ORY_SDK_URL
? fetch(`${process.env.NEXT_PUBLIC_ORY_SDK_URL}/sessions/whoami`, {
headers: {
cookie: request.headers.get("cookie") || "",
},
})
.then((resp) => {
// there must've been no response (invalid URL or something...)
if (!resp) {
return NextResponse.redirect(
new URL(
`/error?error=${JSON.stringify({
message:
"Network error - this could be related to CORS or an incorrect URL set on the `NEXT_PUBLIC_ORY_SDK_URL` environment variable. " +
"Please check out the Ory documentation for more information: https://www.ory.sh/docs/getting-started/local-development",
})}`,
request.url,
),
)
}

console.log(
`Global Session Middleware: ${JSON.stringify(resp.json())}`,
)

// the user is not signed in
if (resp.status === 401) {
return NextResponse.redirect(new URL("/login", request.url))
}

return NextResponse.next()
? fetch(`${process.env.NEXT_PUBLIC_ORY_SDK_URL}/sessions/whoami`, {
headers: {
cookie: request.headers.get("cookie") || "",
},
})
.catch((err) => {
console.log(`Global Session Middleware error: ${JSON.stringify(err)}`)
if (!err.response)
return NextResponse.redirect(
new URL(
`/error?error=${JSON.stringify({
message:
"Network error - this could be related to CORS or an incorrect URL set on the `NEXT_PUBLIC_ORY_SDK_URL` environment variable. " +
"Please check out the Ory documentation for more information: https://www.ory.sh/docs/getting-started/local-development",
})}`,
request.url,
),
)

switch (err.response?.status) {
// 422 we need to redirect the user to the location specified in the response
case 422:
.then((resp) => {
// there must've been no response (invalid URL or something...)
if (!resp) {
return NextResponse.redirect(
err.response.data.redirect_browser_to,
new URL(
`/error?error=${JSON.stringify({
message:
"Network error - this could be related to CORS or an incorrect URL set on the `NEXT_PUBLIC_ORY_SDK_URL` environment variable. " +
"Please check out the Ory documentation for more information: https://www.ory.sh/docs/getting-started/local-development",
})}`,
request.url,
),
)
//return router.push("/login", { query: { aal: "aal2" } })
case 401:
// The user is not logged in, so we redirect them to the login page.
}

console.log(
`Global Session Middleware: ${JSON.stringify(resp.json())}`,
)

// the user is not signed in
if (resp.status === 401) {
return NextResponse.redirect(new URL("/login", request.url))
case 404:
// the SDK is not configured correctly
// we set this up so you can debug the issue in the browser
return NextResponse.redirect(
new URL(`/error?error=${JSON.stringify(err)}`, request.url),
)
default:
}

return NextResponse.next()
})
.catch((err) => {
console.log(
`Global Session Middleware error: ${JSON.stringify(err)}`,
)
if (!err.response)
return NextResponse.redirect(
new URL(`/error?error=${JSON.stringify(err)}`, request.url),
new URL(
`/error?error=${JSON.stringify({
message:
"Network error - this could be related to CORS or an incorrect URL set on the `NEXT_PUBLIC_ORY_SDK_URL` environment variable. " +
"Please check out the Ory documentation for more information: https://www.ory.sh/docs/getting-started/local-development",
})}`,
request.url,
),
)
}
})
: NextResponse.redirect(
new URL(
`/error?error=${JSON.stringify({
message: "NEXT_PUBLIC_ORY_SDK_URL env variable is not set",
})}`,
request.url,
),
)

switch (err.response?.status) {
// 422 we need to redirect the user to the location specified in the response
case 422:
return NextResponse.redirect(
err.response.data.redirect_browser_to,
)
//return router.push("/login", { query: { aal: "aal2" } })
case 401:
// The user is not logged in, so we redirect them to the login page.
return NextResponse.redirect(new URL("/login", request.url))
case 404:
// the SDK is not configured correctly
// we set this up so you can debug the issue in the browser
return NextResponse.redirect(
new URL(`/error?error=${JSON.stringify(err)}`, request.url),
)
default:
return NextResponse.redirect(
new URL(`/error?error=${JSON.stringify(err)}`, request.url),
)
}
})
: NextResponse.redirect(
new URL(
`/error?error=${JSON.stringify({
message: "NEXT_PUBLIC_ORY_SDK_URL env variable is not set",
})}`,
request.url,
),
)
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "root",
"prettier": "ory-prettier-styles",
"private": "true",
"scripts": {
"storybook": "storybook dev -p 6006",
Expand Down Expand Up @@ -74,7 +73,6 @@
"jest": "29.7.0",
"license-checker": "25.0.1",
"nx": "19.5.4",
"ory-prettier-styles": "1.3.0",
"playwright": "1.46.0",
"postcss": "8.4.35",
"prettier": "3.0.3",
Expand Down
12 changes: 6 additions & 6 deletions src/react-components/ory/helpers/filter-flow-nodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ export const FilterFlowNodes = ({
isUiNodeInputAttributes(node.attributes)
? node.attributes.name
: isUiNodeImageAttributes(node.attributes)
? node.attributes.src
: isUiNodeAnchorAttributes(node.attributes) ||
isUiNodeTextAttributes(node.attributes) ||
isUiNodeScriptAttributes(node.attributes)
? node.attributes.id
: k
? node.attributes.src
: isUiNodeAnchorAttributes(node.attributes) ||
isUiNodeTextAttributes(node.attributes) ||
isUiNodeScriptAttributes(node.attributes)
? node.attributes.id
: k
}
{...overrides}
/>
Expand Down

0 comments on commit 412dc03

Please sign in to comment.