refactored email verification

This commit is contained in:
daniel31x13
2024-05-16 15:02:22 -04:00
parent db446d450f
commit f68ca100a1
16 changed files with 1285 additions and 135 deletions
+33
View File
@@ -0,0 +1,33 @@
import { useRouter } from "next/router";
import { useEffect } from "react";
import toast from "react-hot-toast";
const VerifyEmail = () => {
const router = useRouter();
useEffect(() => {
const token = router.query.token;
if (!token || typeof token !== "string") {
router.push("/login");
}
// Verify token
fetch(`/api/v1/auth/verify-email?token=${token}`, {
method: "POST",
}).then((res) => {
if (res.ok) {
toast.success("Email verified. You can now login.");
} else {
toast.error("Invalid token.");
}
});
console.log(token);
}, []);
return <div>Verify email...</div>;
};
export default VerifyEmail;