From fe1c5cc83af26ccbd98c9dc0fc7a49b58a1dd0ff Mon Sep 17 00:00:00 2001
From: Markus Thielker
Date: Thu, 26 Dec 2024 12:31:41 +0100
Subject: [PATCH 1/4] NORY-26: add protocol to middleware redirects
---
authentication/src/middleware.ts | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/authentication/src/middleware.ts b/authentication/src/middleware.ts
index c4c06ed..d7c682a 100644
--- a/authentication/src/middleware.ts
+++ b/authentication/src/middleware.ts
@@ -12,14 +12,13 @@ export async function middleware(request: NextRequest) {
.then((response) => response.data)
.catch(() => null);
+ const nodeHost = request.nextUrl.protocol + '//' + request.nextUrl.host;
+
if (!session && !request.nextUrl.pathname.startsWith('/flow')) {
console.log('NO SESSION');
- const url = request.nextUrl.host +
- '/flow/login?return_to=' +
- request.nextUrl.host +
- request.nextUrl.pathname;
+ const url = nodeHost + '/flow/login?return_to=' + request.nextUrl.toString();
console.log('REDIRECT TO', url);
@@ -30,7 +29,7 @@ export async function middleware(request: NextRequest) {
console.log('SESSION EXISTS');
- const returnTo = request.nextUrl.searchParams.get('return_to') ?? request.nextUrl.host;
+ const returnTo = request.nextUrl.searchParams.get('return_to') ?? nodeHost;
console.log('REDIRECT TO', returnTo);
@@ -41,5 +40,5 @@ export async function middleware(request: NextRequest) {
}
export const config = {
- matcher: '/((?!api|_next/static|_next/image|favicon.png|sitemap.xml|robots.txt|sw.js).*)',
+ matcher: '/((?!api|_next/static|_next/image|favicon.png|sitemap.xml|robots.txt|sw.js|manifest.json|icon-72.png|icon-128.png|icon-144.png|icon-192.png|icon-512.png|mt-logo-orange.png).*)',
};
From b2552cb729c20104e15b32ef3e6c79c07f759504 Mon Sep 17 00:00:00 2001
From: Markus Thielker
Date: Thu, 26 Dec 2024 12:32:29 +0100
Subject: [PATCH 2/4] NORY-26: add documentation for setting up an admin
account
---
README.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/README.md b/README.md
index cdfd27b..8a10ca6 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,9 @@ bun install
bun run dev
```
+Create an account using the authentication UI on http://localhost:3000.
+The verification code can be found on the dummy SMTP dashboard on http://localhost:4436.
+
Inside another terminal session we can start the dashboard UI:
```bash
From b903517e88d0e8561a0d93aa2e04c3fc191b130b Mon Sep 17 00:00:00 2001
From: Markus Thielker
Date: Thu, 26 Dec 2024 12:34:53 +0100
Subject: [PATCH 3/4] NORY-26: remove case on top of error handling
---
authentication/src/ory/hooks.tsx | 6 ------
1 file changed, 6 deletions(-)
diff --git a/authentication/src/ory/hooks.tsx b/authentication/src/ory/hooks.tsx
index 5c81e04..a03dd8d 100644
--- a/authentication/src/ory/hooks.tsx
+++ b/authentication/src/ory/hooks.tsx
@@ -18,12 +18,6 @@ export const HandleError = (
return async (
error: AxiosError,
): Promise => {
- if (!error.response || error.response?.status === 0) {
- window.location.href = `/flow/error?error=${encodeURIComponent(
- JSON.stringify(error.response),
- )}`;
- return Promise.resolve();
- }
const responseData = error.response?.data || {};
From cb1812cde0ca2257a6733c3e810ad3b23e26f329 Mon Sep 17 00:00:00 2001
From: Markus Thielker
Date: Thu, 26 Dec 2024 15:37:20 +0100
Subject: [PATCH 4/4] NORY-26: limit error width and add horizontal margin
---
authentication/src/app/flow/error/page.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/authentication/src/app/flow/error/page.tsx b/authentication/src/app/flow/error/page.tsx
index e35626f..fa87dc4 100644
--- a/authentication/src/app/flow/error/page.tsx
+++ b/authentication/src/app/flow/error/page.tsx
@@ -51,7 +51,7 @@ export default function Error() {
return (
<>
-
+
An error occurred
@@ -61,7 +61,7 @@ export default function Error() {
-