forked from cms/tibi-svelte-starter
init
This commit is contained in:
25
api/hooks/contact_form/post_create.js
Normal file
25
api/hooks/contact_form/post_create.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// @ts-check
|
||||
/**
|
||||
* @typedef {import('../types') }
|
||||
*/
|
||||
|
||||
var utils = require("../lib/utils")
|
||||
|
||||
;(function () {
|
||||
if (utils.isPublicToken(context)) {
|
||||
// js captcha
|
||||
var checksum = context.request().query("cs")
|
||||
var email = context.data.email
|
||||
if (!email || (email.length * 1000).toString(16) + "x" !== checksum) {
|
||||
throw {
|
||||
status: 403,
|
||||
error: "forbidden data",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {import('../types').HookResponse} */
|
||||
// @ts-ignore
|
||||
var response = null
|
||||
return response
|
||||
})()
|
||||
37
api/hooks/contact_form/post_return.js
Normal file
37
api/hooks/contact_form/post_return.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// @ts-check
|
||||
/**
|
||||
* @typedef {import('../types') }
|
||||
*/
|
||||
|
||||
var config = require("../config")
|
||||
var utils = require("../lib/utils")
|
||||
|
||||
;(function () {
|
||||
if (utils.isPublicToken(context)) {
|
||||
var emailFrom = context.data.email
|
||||
var emailFromName =
|
||||
(context.data.firstname || "") +
|
||||
(context.data.firstname && context.data.lastname && " ") +
|
||||
(context.data.lastname || "")
|
||||
|
||||
context.mail({
|
||||
to: config.operatorEmail,
|
||||
from: emailFrom,
|
||||
fromName: emailFromName,
|
||||
subject: utils.tpl(
|
||||
context,
|
||||
"templates/operator_contact_form_subject.de.txt"
|
||||
),
|
||||
html: utils.tpl(
|
||||
context,
|
||||
"templates/operator_contact_form_body.de.html"
|
||||
),
|
||||
// attach: ["attachments/AGB.pdf"],
|
||||
})
|
||||
}
|
||||
|
||||
/** @type {import('../types').HookResponse} */
|
||||
// @ts-ignore
|
||||
var response = null
|
||||
return response
|
||||
})()
|
||||
Reference in New Issue
Block a user