- {isEmailSent ? "Email Sent!" : "Forgot Password?"}
+ {requestSent ? "Password Updated!" : "Reset Password"}
- {!isEmailSent ? (
+ {!requestSent ? (
<>
@@ -76,12 +80,12 @@ export default function ResetPassword() {
-
Email
+
New Password
@@ -92,23 +96,22 @@ export default function ResetPassword() {
>
) : (
-
- Check your email for a link to reset your password. If it doesn’t
- appear within a few minutes, check your spam folder.
-
- )}
+ <>
+ Your password has been successfully updated.
-
-
- Go back
-
-
+
+
+ Back to Login
+
+
+ >
+ )}
diff --git a/pages/confirmation.tsx b/pages/confirmation.tsx
index 1fee8d2..f8f99b6 100644
--- a/pages/confirmation.tsx
+++ b/pages/confirmation.tsx
@@ -1,8 +1,33 @@
import CenteredForm from "@/layouts/CenteredForm";
+import { signIn } from "next-auth/react";
import Link from "next/link";
-import React from "react";
+import { useRouter } from "next/router";
+import React, { useState } from "react";
+import toast from "react-hot-toast";
export default function EmailConfirmaion() {
+ const router = useRouter();
+
+ const [submitLoader, setSubmitLoader] = useState(false);
+
+ const resend = async () => {
+ setSubmitLoader(true);
+
+ const load = toast.loading("Authenticating...");
+
+ const res = await signIn("email", {
+ email: decodeURIComponent(router.query.email as string),
+ callbackUrl: "/",
+ redirect: false,
+ });
+
+ toast.dismiss(load);
+
+ setSubmitLoader(false);
+
+ toast.success("Verification email sent.");
+ };
+
return (
@@ -12,15 +37,16 @@ export default function EmailConfirmaion() {
-
A sign in link has been sent to your email address.
-
-
- Didn't see the email? Check your spam folder or visit the{" "}
-
- Password Recovery
- {" "}
- page to resend the link.
+
+ A sign in link has been sent to your email address. If you don't see
+ the email, check your spam folder.
+
+
);
diff --git a/pages/forgot.tsx b/pages/forgot.tsx
index f216776..70dc8af 100644
--- a/pages/forgot.tsx
+++ b/pages/forgot.tsx
@@ -94,15 +94,15 @@ export default function Forgot() {
/>
>
) : (
-
+
Check your email for a link to reset your password. If it doesn’t
appear within a few minutes, check your spam folder.
)}
-
-
- Go back
+
+
+ Back to Login
diff --git a/pages/login.tsx b/pages/login.tsx
index 1824afe..90d26d1 100644
--- a/pages/login.tsx
+++ b/pages/login.tsx
@@ -47,7 +47,7 @@ export default function Login({
setSubmitLoader(false);
if (!res?.ok) {
- toast.error("Invalid login.");
+ toast.error(res?.error || "Invalid credentials.");
}
} else {
toast.error("Please fill out all the fields.");
@@ -108,7 +108,7 @@ export default function Login({
Forgot Password?
@@ -158,7 +158,7 @@ export default function Login({
New here?
Sign Up
diff --git a/pages/register.tsx b/pages/register.tsx
index eb5c602..c3d63b1 100644
--- a/pages/register.tsx
+++ b/pages/register.tsx
@@ -76,12 +76,17 @@ export default function Register() {
setSubmitLoader(false);
if (response.ok) {
- if (form.email && emailEnabled)
+ if (form.email && emailEnabled) {
await signIn("email", {
email: form.email,
callbackUrl: "/",
+ redirect: false,
});
- else if (!emailEnabled) router.push("/login");
+
+ router.push(
+ "/confirmation?email=" + encodeURIComponent(form.email)
+ );
+ } else if (!emailEnabled) router.push("/login");
toast.success("User Created!");
} else {