Oops!
-
There was an unexpected error while trying to reset your password.
-
Please try again later or contact us.
+
There was an error while trying to reset your password. Your password-reset token might be invalid or expired.
+
Please try requesting a new password reset or contact us.
)
}
- return (
-
+
{isLoading &&
@@ -90,14 +91,14 @@ const LoginPage = () => {
[
{link: '/register', linkText: 'Don\'t have an account?'},
{link: '/reset-password', linkText: 'Forgot your password?'},
- {link: '/resend-confirmation-email', linkText: 'Haven\'t received confirmation email yet?'},
+ {link: '/resend-confirm-email', linkText: 'Haven\'t received confirmation email yet?'},
]
}
/>
-
+
)
}
diff --git a/app/(account)/reset-password/[token]/page.tsx b/app/(account)/reset-password/[token]/page.tsx
index b3e4e99..b52e520 100644
--- a/app/(account)/reset-password/[token]/page.tsx
+++ b/app/(account)/reset-password/[token]/page.tsx
@@ -9,6 +9,7 @@ import Button from "../../../common/uiLibrary/Button";
import {useFormState} from "react-dom";
import {postPasswordReset, ResetPasswordStep2Response} from "./actions";
import {isFieldError} from "../../../../lib/auth/guards";
+import FullPage from "../../../common/uiLibrary/Layouters/fullPage";
const ResetPasswordPageStep2 = () => {
const {token} = useParams<{ token: string }>();
@@ -79,13 +80,13 @@ const ResetPasswordPageStep2 = () => {
}
return (
-
+
{state.success ? successMessage() : resetPasswordForm()}
-
+
)
}
diff --git a/app/common/uiLibrary/Layouters/fullPage.tsx b/app/common/uiLibrary/Layouters/fullPage.tsx
new file mode 100644
index 0000000..ef34bfa
--- /dev/null
+++ b/app/common/uiLibrary/Layouters/fullPage.tsx
@@ -0,0 +1,12 @@
+import layoutChildren from "../../../../types/layoutChildren";
+
+// makes the view occupy the full page, excluding the header.
+const FullPage = (props: layoutChildren) => {
+ return (
+
+ {props.children}
+
+ )
+}
+
+export default FullPage;
\ No newline at end of file
From be84832f1bf28afbda3514f2b946b55750683395 Mon Sep 17 00:00:00 2001
From: Gilles <43683714+corp-0@users.noreply.github.com>
Date: Sat, 9 Mar 2024 17:12:28 -0300
Subject: [PATCH 13/16] feat: add page to resend confirmation email
---
app/(account)/resend-confirm-email/actions.ts | 53 ++++++++++++++
app/(account)/resend-confirm-email/page.tsx | 70 +++++++++++++++++++
2 files changed, 123 insertions(+)
create mode 100644 app/(account)/resend-confirm-email/actions.ts
create mode 100644 app/(account)/resend-confirm-email/page.tsx
diff --git a/app/(account)/resend-confirm-email/actions.ts b/app/(account)/resend-confirm-email/actions.ts
new file mode 100644
index 0000000..5ff606f
--- /dev/null
+++ b/app/(account)/resend-confirm-email/actions.ts
@@ -0,0 +1,53 @@
+"use server"
+
+import {z} from 'zod';
+import {FieldError, GeneralError, isFieldError} from "../../../lib/auth/guards";
+
+export interface ResendConfirmationMailRequest {
+ success: boolean;
+ error?: GeneralError | FieldError;
+}
+
+export const postResendConfirmationMail = async (_: ResendConfirmationMailRequest, formData: FormData): Promise
=> {
+ const schema = z.object({
+ email: z.string().email()
+ });
+
+ const parsed = schema.safeParse({
+ email: formData.get('email')
+ });
+
+ if (!parsed.success) {
+ const fieldErrors = parsed.error.errors.reduce((acc, error) => {
+ return {...acc, [error.path[0]]: error.message}
+ }, {});
+
+ return {success: false, error: {status: 400, error: fieldErrors}};
+ }
+
+ try {
+ const response = await fetch(`${process.env.CC_API_URL}/accounts/resend-account-confirmation`, {
+ method: "POST",
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ email: parsed.data.email
+ })
+ });
+
+ if (!response.ok) {
+ const error = await response.json();
+ if (isFieldError(error)) {
+ return {success: false, error: error};
+ }
+
+ throw new Error('Unknown error');
+ }
+
+ } catch (e) {
+ return {success: false, error: {error: 'An unexpected error happened', status: 500}};
+ }
+
+ return {success: true}
+}
\ No newline at end of file
diff --git a/app/(account)/resend-confirm-email/page.tsx b/app/(account)/resend-confirm-email/page.tsx
new file mode 100644
index 0000000..156ca55
--- /dev/null
+++ b/app/(account)/resend-confirm-email/page.tsx
@@ -0,0 +1,70 @@
+"use client"
+
+
+import FormContainer from "../../common/uiLibrary/Layouters/formContainer";
+import TextField from "../../common/uiLibrary/forms/textField";
+import Button from "../../common/uiLibrary/Button";
+import ContactInformation from "../../(home)/contactInformation";
+import React from "react";
+import FullPage from "../../common/uiLibrary/Layouters/fullPage";
+import {useFormState} from "react-dom";
+import {postResendConfirmationMail, ResendConfirmationMailRequest} from "./actions";
+
+const ResendConfirmationMail = () => {
+ const initialState: ResendConfirmationMailRequest = {
+ success: false,
+ }
+
+ const [state, formAction] = useFormState(postResendConfirmationMail, initialState);
+
+ const resendForm = () => {
+ return (
+ <>
+ {!state.success && state.error && errorMessage()}
+
+
+ Submit
+ >
+ )
+ }
+ const errorMessage = () => {
+ return (
+
+
Oops!
+
There was an unexpected error while trying to resend the confirmation email.
+
Please try again later or contact us.
+
+ )
+ }
+
+ const successMessage = () => (
+
+
Success!
+
Your request has been processed successfully. If your account is found in our system and the email
+ address you provided matches our records, we have sent a confirmation email to that address.
+
Please check your inbox for the confirmation email. If you don't receive it within a few minutes, check
+ your spam or junk folder. For further assistance, don't hesitate to contact us.
+
+ );
+
+ return (
+
+
+
+ {state.success ? successMessage() : resendForm()}
+
+
+
+
+ )
+};
+
+export default ResendConfirmationMail;
\ No newline at end of file
From 4ae8d4250c3e23a8baedff4477804306075ce2a9 Mon Sep 17 00:00:00 2001
From: Gilles <43683714+corp-0@users.noreply.github.com>
Date: Sat, 9 Mar 2024 17:16:43 -0300
Subject: [PATCH 14/16] chore: fuck you linter
---
app/(account)/resend-confirm-email/page.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/(account)/resend-confirm-email/page.tsx b/app/(account)/resend-confirm-email/page.tsx
index 156ca55..86f6777 100644
--- a/app/(account)/resend-confirm-email/page.tsx
+++ b/app/(account)/resend-confirm-email/page.tsx
@@ -50,8 +50,8 @@ const ResendConfirmationMail = () => {
Success!
Your request has been processed successfully. If your account is found in our system and the email
address you provided matches our records, we have sent a confirmation email to that address.
- Please check your inbox for the confirmation email. If you don't receive it within a few minutes, check
- your spam or junk folder. For further assistance, don't hesitate to contact us.
+ Please check your inbox for the confirmation email. If you don't receive it within a few minutes, check
+ your spam or junk folder. For further assistance, don't hesitate to contact us.
);
From db12e840d06ffa65c6d416b45f1a850221e9f32f Mon Sep 17 00:00:00 2001
From: Gilles <43683714+corp-0@users.noreply.github.com>
Date: Sat, 9 Mar 2024 17:19:02 -0300
Subject: [PATCH 15/16] chore: remove unused import
---
app/(account)/confirm-email/[token]/actions.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/(account)/confirm-email/[token]/actions.ts b/app/(account)/confirm-email/[token]/actions.ts
index deedb65..d555853 100644
--- a/app/(account)/confirm-email/[token]/actions.ts
+++ b/app/(account)/confirm-email/[token]/actions.ts
@@ -1,6 +1,6 @@
"use server"
-import {isFieldError, isGeneralError} from "../../../../lib/auth/guards";
+import {isFieldError} from "../../../../lib/auth/guards";
export const postMailConfirmationToken = async (token: string): Promise