mirror of
https://github.com/sergeyyarkov/yarkov.tech.git
synced 2026-10-12 10:59:08 +03:00
added honeypot field on contact form
This commit is contained in:
parent
97fa1a5b4e
commit
b7b0a6f4d5
@ -11,10 +11,13 @@ export const server = {
|
|||||||
input: z.object({
|
input: z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
email: z.string().email(),
|
email: z.string().email(),
|
||||||
|
website_url: z.string().optional(), // honeypot field
|
||||||
subject: z.string(),
|
subject: z.string(),
|
||||||
message: z.string(),
|
message: z.string(),
|
||||||
}),
|
}),
|
||||||
handler: async (data, ctx) => {
|
handler: async (data, ctx) => {
|
||||||
|
if (data.website_url && data.website_url.trim() !== "") return true;
|
||||||
|
|
||||||
const currentDate = new Date();
|
const currentDate = new Date();
|
||||||
const latestAppeals = await getLatestAppealsByClientIp(ctx.clientAddress, 5);
|
const latestAppeals = await getLatestAppealsByClientIp(ctx.clientAddress, 5);
|
||||||
const appealsLastHrs = latestAppeals.filter((a) => {
|
const appealsLastHrs = latestAppeals.filter((a) => {
|
||||||
|
|||||||
@ -17,6 +17,10 @@ const formResult = Astro.getActionResult(actions.appeal);
|
|||||||
<div>
|
<div>
|
||||||
<input name="email" placeholder="example@email.com" type="email" autocomplete="off" required />
|
<input name="email" placeholder="example@email.com" type="email" autocomplete="off" required />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="hp-field" aria-hidden="true">
|
||||||
|
<label for="website_url">Оставьте это поле пустым:</label>
|
||||||
|
<input type="text" autocomplete="off" id="website_url" name="website_url" tabindex="-1" autocomplete="off" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input name="subject" placeholder={t("input.subjectField")} type="text" autocomplete="off" required />
|
<input name="subject" placeholder={t("input.subjectField")} type="text" autocomplete="off" required />
|
||||||
<textarea
|
<textarea
|
||||||
@ -48,6 +52,13 @@ const formResult = Astro.getActionResult(actions.appeal);
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
row-gap: 7px;
|
row-gap: 7px;
|
||||||
margin-bottom: 3.125rem;
|
margin-bottom: 3.125rem;
|
||||||
|
& .hp-field {
|
||||||
|
position: absolute;
|
||||||
|
left: -9999px;
|
||||||
|
top: -9999px;
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
& .flex {
|
& .flex {
|
||||||
column-gap: 10px;
|
column-gap: 10px;
|
||||||
& div {
|
& div {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user