Skip to content

The Open Source DocuSign Alternative.

fix: code style updates and email wording changes

Mythied3f82e1eb0d7
diff --git a/apps/web/components/reset-password.tsx b/apps/web/components/reset-password.tsx
index 954a6b0da..9f5f1d466 100644
--- a/apps/web/components/reset-password.tsx
+++ b/apps/web/components/reset-password.tsx
@@ -5,11 +5,11 @@ import { Button } from "@documenso/ui";
import Logo from "./logo";
import { ArrowLeftIcon } from "@heroicons/react/24/outline";
import { zodResolver } from "@hookform/resolvers/zod";
-import { FormProvider, useForm } from "react-hook-form";
+import { useForm } from "react-hook-form";
import { toast } from "react-hot-toast";
import * as z from "zod";
-const schema = z
+const ZResetPasswordFormSchema = z
.object({
password: z.string().min(8, { message: "Password must be at least 8 characters" }),
confirmPassword: z.string().min(8, { message: "Password must be at least 8 characters" }),
@@ -19,7 +19,7 @@ const schema = z
message: "Password don't match",
});
-type ResetPasswordForm = z.infer<typeof schema>;
+type TResetPasswordFormSchema = z.infer<typeof ZResetPasswordFormSchema>;
export default function ResetPassword() {
const router = useRouter();
@@ -29,20 +29,20 @@ export default function ResetPassword() {
register,
formState: { errors, isSubmitting },
handleSubmit,
- } = useForm<ResetPasswordForm>({
- resolver: zodResolver(schema),
+ } = useForm<TResetPasswordFormSchema>({
+ resolver: zodResolver(ZResetPasswordFormSchema),
});
const [resetSuccessful, setResetSuccessful] = useState(false);
- const onSubmit = async (values: ResetPasswordForm) => {
+ const onSubmit = async ({ password }: TResetPasswordFormSchema) => {
const response = await toast.promise(
fetch(`/api/auth/reset-password`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
- body: JSON.stringify({ password: values.password, token }),
+ body: JSON.stringify({ password, token }),
}),
{
loading: "Resetting...",
@@ -96,6 +96,7 @@ export default function ResetPassword() {
placeholder="New password"
/>
</div>
+
<div>
<label htmlFor="confirmPassword" className="sr-only">
Password
@@ -126,6 +127,7 @@ export default function ResetPassword() {
</div>
</form>
)}
+
<div>
<Link href="/login">
<div className="relative mt-10 flex items-center justify-center gap-2 text-sm text-gray-500 hover:cursor-pointer hover:text-gray-900">
diff --git a/apps/web/pages/api/auth/forgot-password.ts b/apps/web/pages/api/auth/forgot-password.ts
index 9a17edd9f..98e4a6676 100644
--- a/apps/web/pages/api/auth/forgot-password.ts
+++ b/apps/web/pages/api/auth/forgot-password.ts
@@ -9,7 +9,7 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
const cleanEmail = email.toLowerCase();
if (!cleanEmail || !/.+@.+/.test(cleanEmail)) {
- res.status(422).json({ message: "Invalid email" });
+ res.status(400).json({ message: "Invalid email" });
return;
}
diff --git a/apps/web/pages/api/auth/signup.ts b/apps/web/pages/api/auth/signup.ts
index d8032ed95..b67f1b50f 100644
--- a/apps/web/pages/api/auth/signup.ts
+++ b/apps/web/pages/api/auth/signup.ts
@@ -9,12 +9,12 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
const cleanEmail = email.toLowerCase();
if (!cleanEmail || !/.+@.+/.test(cleanEmail)) {
- res.status(422).json({ message: "Invalid email" });
+ res.status(400).json({ message: "Invalid email" });
return;
}
if (!password || password.trim().length < 7) {
- return res.status(422).json({
+ return res.status(400).json({
message: "Password should be at least 7 characters long.",
});
}
diff --git a/packages/lib/mail/resetPasswordSuccessTemplate.ts b/packages/lib/mail/resetPasswordSuccessTemplate.ts
index 44afcc119..25a0a9ff5 100644
--- a/packages/lib/mail/resetPasswordSuccessTemplate.ts
+++ b/packages/lib/mail/resetPasswordSuccessTemplate.ts
@@ -20,7 +20,7 @@ export const resetPasswordSuccessTemplate = (user: User) => {
</p>
<p style="margin-top: 15px">
- If you did not ask to change your password we are here to help you secure your account, just <a href="https://documenso.com">contact us</a>.
+ Didn't request a password change? We are here to help you secure your account, just <a href="https://documenso.com">contact us</a>.
</p>
<p style="margin-top: 15px">