fix: redirect to 404 page for invalid email verification token (#9499)
* fix:redirect to 404 page for invalid email token * update 404 page to include invalid token error * fix: use i18n Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> --------- Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> Co-authored-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
This commit is contained in:
parent
212f7a374f
commit
f469a9c127
|
@ -42,6 +42,10 @@ export default function Custom404() {
|
||||||
const isSubpage = router.asPath.includes("/", 2) || isSuccessPage;
|
const isSubpage = router.asPath.includes("/", 2) || isSuccessPage;
|
||||||
const isSignup = router.asPath.startsWith("/signup");
|
const isSignup = router.asPath.startsWith("/signup");
|
||||||
const isCalcom = process.env.NEXT_PUBLIC_WEBAPP_URL === "https://app.cal.com";
|
const isCalcom = process.env.NEXT_PUBLIC_WEBAPP_URL === "https://app.cal.com";
|
||||||
|
|
||||||
|
// In case of invalid email verification token, we intentionally redirect to 404 from the API
|
||||||
|
const isInvalidToken = router.asPath === "/404";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If we're on 404 and the route is insights it means it is disabled
|
* If we're on 404 and the route is insights it means it is disabled
|
||||||
* TODO: Abstract this for all disabled features
|
* TODO: Abstract this for all disabled features
|
||||||
|
@ -200,12 +204,18 @@ export default function Custom404() {
|
||||||
{t("error_404")}
|
{t("error_404")}
|
||||||
</p>
|
</p>
|
||||||
<h1 className="font-cal text-emphasis mt-2 text-4xl font-extrabold sm:text-5xl">
|
<h1 className="font-cal text-emphasis mt-2 text-4xl font-extrabold sm:text-5xl">
|
||||||
{isSuccessPage ? "Booking not found" : t("page_doesnt_exist")}
|
{isSuccessPage
|
||||||
|
? t("booking_not_found")
|
||||||
|
: isInvalidToken
|
||||||
|
? t("invalid_verification_link")
|
||||||
|
: t("page_doesnt_exist")}
|
||||||
</h1>
|
</h1>
|
||||||
{isSubpage ? (
|
{isSubpage ? (
|
||||||
<span className="mt-2 inline-block text-lg ">
|
<span className="mt-2 inline-block text-lg ">
|
||||||
{t("check_spelling_mistakes_or_go_back")}
|
{t("check_spelling_mistakes_or_go_back")}
|
||||||
</span>
|
</span>
|
||||||
|
) : isInvalidToken ? (
|
||||||
|
<span className="mt-2 inline-block text-lg">{t("token_invalid_expired")}</span>
|
||||||
) : isCalcom ? (
|
) : isCalcom ? (
|
||||||
<a target="_blank" href={url} className="mt-2 inline-block text-lg" rel="noreferrer">
|
<a target="_blank" href={url} className="mt-2 inline-block text-lg" rel="noreferrer">
|
||||||
{t("the_username")}{" "}
|
{t("the_username")}{" "}
|
||||||
|
|
|
@ -19,11 +19,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!foundToken) {
|
if (!foundToken) {
|
||||||
return res.status(401).json({ message: "No token found" });
|
return res.redirect(`${WEBAPP_URL}/404`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dayjs(foundToken?.expires).isBefore(dayjs())) {
|
if (dayjs(foundToken?.expires).isBefore(dayjs())) {
|
||||||
return res.status(401).json({ message: "Token expired" });
|
return res.redirect(`${WEBAPP_URL}/404`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await prisma.user.update({
|
const user = await prisma.user.update({
|
||||||
|
|
|
@ -349,6 +349,7 @@
|
||||||
"no_status_bookings_yet_description": "You have no {{status}} bookings. {{description}}",
|
"no_status_bookings_yet_description": "You have no {{status}} bookings. {{description}}",
|
||||||
"event_between_users": "{{eventName}} between {{host}} and {{attendeeName}}",
|
"event_between_users": "{{eventName}} between {{host}} and {{attendeeName}}",
|
||||||
"bookings": "Bookings",
|
"bookings": "Bookings",
|
||||||
|
"booking_not_found":"Booking not found",
|
||||||
"bookings_description": "See upcoming and past events booked through your event type links.",
|
"bookings_description": "See upcoming and past events booked through your event type links.",
|
||||||
"upcoming_bookings": "As soon as someone books a time with you it will show up here.",
|
"upcoming_bookings": "As soon as someone books a time with you it will show up here.",
|
||||||
"recurring_bookings": "As soon as someone books a recurring meeting with you it will show up here.",
|
"recurring_bookings": "As soon as someone books a recurring meeting with you it will show up here.",
|
||||||
|
@ -1725,6 +1726,7 @@
|
||||||
"app_is_connected": "{{dependencyName}} is connected",
|
"app_is_connected": "{{dependencyName}} is connected",
|
||||||
"requires_app": "Requires {{dependencyName}}",
|
"requires_app": "Requires {{dependencyName}}",
|
||||||
"verification_code": "Verification code",
|
"verification_code": "Verification code",
|
||||||
|
"invalid_verification_link": "Invalid verification link",
|
||||||
"can_you_try_again": "Can you try again with a different time?",
|
"can_you_try_again": "Can you try again with a different time?",
|
||||||
"verify": "Verify",
|
"verify": "Verify",
|
||||||
"timezone_info": "The timezone of the person receiving",
|
"timezone_info": "The timezone of the person receiving",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user