From 002b22b1a88d52823ebea215ae074a6d6b9b8ff8 Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Mon, 5 Jun 2023 12:50:11 +0000 Subject: [PATCH] Add forgot password page --- apps/web/components/forgot-password.tsx | 77 +++++++++++++++++++++++++ apps/web/components/login.tsx | 6 +- apps/web/pages/forgot-password.tsx | 34 +++++++++++ 3 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 apps/web/components/forgot-password.tsx create mode 100644 apps/web/pages/forgot-password.tsx diff --git a/apps/web/components/forgot-password.tsx b/apps/web/components/forgot-password.tsx new file mode 100644 index 000000000..30a7eb036 --- /dev/null +++ b/apps/web/components/forgot-password.tsx @@ -0,0 +1,77 @@ +import Link from "next/link"; +import { Button } from "@documenso/ui"; +import Logo from "./logo"; +import { ArrowLeftIcon } from "@heroicons/react/24/outline"; +import { FormProvider, useForm } from "react-hook-form"; + +interface IResetPassword { + email: string; +} + +export default function ForgotPassword(props: any) { + const methods = useForm(); + const { register, formState, resetField } = methods; + + const onSubmit = async (values: IResetPassword) => { + resetField("email"); + + console.log(values); + }; + + return ( + <> +
+
+
+ +

+ Forgot Password? +

+

+ No worries, we'll send you reset instructions. +

+
+ +
+ +
+
+ + +
+
+ +
+ +
+
+ +
+ + Back to log in +
+ +
+
+
+
+
+ + ); +} diff --git a/apps/web/components/login.tsx b/apps/web/components/login.tsx index 4f086a8e1..f78513d87 100644 --- a/apps/web/components/login.tsx +++ b/apps/web/components/login.tsx @@ -111,9 +111,11 @@ export default function Login(props: any) {
- + Forgot your password? - +
diff --git a/apps/web/pages/forgot-password.tsx b/apps/web/pages/forgot-password.tsx new file mode 100644 index 000000000..ffcf6e470 --- /dev/null +++ b/apps/web/pages/forgot-password.tsx @@ -0,0 +1,34 @@ +import Head from "next/head"; +import { getUserFromToken } from "@documenso/lib/server"; +import ForgotPassword from "../components/forgot-password"; + +export default function ForgotPasswordPage(props: any) { + return ( + <> + + Reset Password | Documenso + + + + ); +} + +export async function getServerSideProps(context: any) { + const user = await getUserFromToken(context.req, context.res); + if (user) + return { + redirect: { + source: "/login", + destination: "/dashboard", + permanent: false, + }, + }; + + const ALLOW_SIGNUP = process.env.NEXT_PUBLIC_ALLOW_SIGNUP === "true"; + + return { + props: { + ALLOW_SIGNUP, + }, + }; +}