mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
Redirect to /login on password reset
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
import { useState } from "react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { Button } from "@documenso/ui";
|
import { Button } from "@documenso/ui";
|
||||||
@ -19,8 +20,10 @@ export default function ResetPassword(props: any) {
|
|||||||
const { register, formState, watch } = methods;
|
const { register, formState, watch } = methods;
|
||||||
const password = watch("password", "");
|
const password = watch("password", "");
|
||||||
|
|
||||||
|
const [resetSuccessful, setResetSuccessful] = useState(false);
|
||||||
|
|
||||||
const onSubmit = async (values: IResetPassword) => {
|
const onSubmit = async (values: IResetPassword) => {
|
||||||
await toast.promise(
|
const response = await toast.promise(
|
||||||
fetch(`/api/auth/reset-password`, {
|
fetch(`/api/auth/reset-password`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
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) {
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="flex min-h-full items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
|
<div className="flex min-h-full items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
|
||||||
|
|||||||
Reference in New Issue
Block a user