Skip to content

The Open Source DocuSign Alternative.

Redirect to /login on password reset

Ephraim Atta-Duncan7c30ee0c3e1a
diff --git a/apps/web/components/reset-password.tsx b/apps/web/components/reset-password.tsx
index 27e214574..d4745ee24 100644
--- a/apps/web/components/reset-password.tsx
+++ b/apps/web/components/reset-password.tsx
@@ -1,3 +1,4 @@
+import { useState } from "react";
import Link from "next/link";
import { useRouter } from "next/router";
import { Button } from "@documenso/ui";
@@ -19,8 +20,10 @@ export default function ResetPassword(props: any) {
const { register, formState, watch } = methods;
const password = watch("password", "");
+ const [resetSuccessful, setResetSuccessful] = useState(false);
+
const onSubmit = async (values: IResetPassword) => {
- await toast.promise(
+ const response = await toast.promise(
fetch(`/api/auth/reset-password`, {
method: "POST",
headers: {
@@ -35,7 +38,12 @@ export default function ResetPassword(props: any) {
}
);
- console.log(values);
+ if (response.ok) {
+ setResetSuccessful(true);
+ setTimeout(() => {
+ router.push("/login");
+ }, 2000);
+ }
};
if (!token) {
@@ -56,6 +64,22 @@ export default function ResetPassword(props: any) {
);
}
+ if (resetSuccessful) {
+ return (
+ <div className="flex min-h-full items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
+ <div className="w-full max-w-md space-y-8">
+ <div>
+ <Logo className="mx-auto h-20 w-auto"></Logo>
+ <h2 className="mt-6 text-center text-3xl font-bold tracking-tight text-gray-900">
+ Reset Password
+ </h2>
+ <p className="mt-2 text-center text-sm text-gray-600">Your password has been reset.</p>
+ </div>
+ </div>
+ </div>
+ );
+ }
+
return (
<>
<div className="flex min-h-full items-center justify-center py-12 px-4 sm:px-6 lg:px-8">