@websy/websy-designs 1.4.15 → 1.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/routes/v1/recaptcha.js +2 -1
- package/dist/websy-designs-es6.debug.js +51 -30
- package/dist/websy-designs-es6.js +266 -238
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +52 -31
- package/dist/websy-designs.js +270 -242
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -12,7 +12,8 @@ router.post('/checkrecaptcha', function (req, res) {
|
|
|
12
12
|
}
|
|
13
13
|
console.log('recaptcha body')
|
|
14
14
|
console.log(body)
|
|
15
|
-
request.post(`https://www.google.com/recaptcha/api/siteverify?secret=${process.env.RECAPTCHA_SECRET}&response=${req.body.grecaptcharesponse}`, body, (err, response, body) => {
|
|
15
|
+
// request.post(`https://www.google.com/recaptcha/api/siteverify?secret=${process.env.RECAPTCHA_SECRET}&response=${req.body.grecaptcharesponse}`, body, (err, response, body) => {
|
|
16
|
+
request.post(`https://www.google.com/recaptcha/api/siteverify`, {form: body}, (err, response, body) => {
|
|
16
17
|
if (err) {
|
|
17
18
|
res.json({ err: err })
|
|
18
19
|
}
|
|
@@ -2004,25 +2004,26 @@ class WebsyForm {
|
|
|
2004
2004
|
checkRecaptcha () {
|
|
2005
2005
|
return new Promise((resolve, reject) => {
|
|
2006
2006
|
if (this.options.useRecaptcha === true) {
|
|
2007
|
-
|
|
2008
|
-
grecaptcha.ready(() => {
|
|
2009
|
-
grecaptcha.execute(
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
}
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
}
|
|
2018
|
-
}, err => {
|
|
2019
|
-
reject(err)
|
|
2007
|
+
if (this.recaptchaValue) {
|
|
2008
|
+
// grecaptcha.ready(() => {
|
|
2009
|
+
// grecaptcha.execute(this.recaptchaValue, { action: 'submit' }).then(token => {
|
|
2010
|
+
this.apiService.add('google/checkrecaptcha', {grecaptcharesponse: this.recaptchaValue}).then(response => {
|
|
2011
|
+
if (response.success && response.success === true) {
|
|
2012
|
+
resolve(true)
|
|
2013
|
+
grecaptcha.reset(`${this.elementId}_recaptcha`, {sitekey: ENVIRONMENT.RECAPTCHA_KEY})
|
|
2014
|
+
}
|
|
2015
|
+
else {
|
|
2016
|
+
resolve(false)
|
|
2017
|
+
}
|
|
2020
2018
|
})
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
//
|
|
2025
|
-
|
|
2019
|
+
// }, err => {
|
|
2020
|
+
// reject(err)
|
|
2021
|
+
// })
|
|
2022
|
+
// })
|
|
2023
|
+
}
|
|
2024
|
+
else {
|
|
2025
|
+
resolve(false)
|
|
2026
|
+
}
|
|
2026
2027
|
}
|
|
2027
2028
|
else {
|
|
2028
2029
|
resolve(true)
|
|
@@ -2092,10 +2093,12 @@ class WebsyForm {
|
|
|
2092
2093
|
recaptchaReady () {
|
|
2093
2094
|
const el = document.getElementById(`${this.elementId}_recaptcha`)
|
|
2094
2095
|
if (el) {
|
|
2095
|
-
grecaptcha.
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2096
|
+
grecaptcha.ready(() => {
|
|
2097
|
+
grecaptcha.render(`${this.elementId}_recaptcha`, {
|
|
2098
|
+
sitekey: ENVIRONMENT.RECAPTCHA_KEY,
|
|
2099
|
+
callback: this.validateRecaptcha.bind(this)
|
|
2100
|
+
})
|
|
2101
|
+
})
|
|
2099
2102
|
}
|
|
2100
2103
|
}
|
|
2101
2104
|
render (update, data) {
|
|
@@ -2150,6 +2153,12 @@ class WebsyForm {
|
|
|
2150
2153
|
`
|
|
2151
2154
|
}
|
|
2152
2155
|
})
|
|
2156
|
+
if (this.options.useRecaptcha === true) {
|
|
2157
|
+
html += `
|
|
2158
|
+
--><div id='${this.elementId}_recaptcha' data-sitekey='${ENVIRONMENT.RECAPTCHA_KEY}' class='websy-form-recaptcha'></div>
|
|
2159
|
+
<div id='${this.elementId}_recaptchaError' class='websy-alert websy-alert-error websy-hidden'>Invalid recaptcha response</div><!--
|
|
2160
|
+
`
|
|
2161
|
+
}
|
|
2153
2162
|
html += `
|
|
2154
2163
|
--><button class="websy-btn submit ${this.options.submit.classes || ''}">${this.options.submit.text || 'Save'}</button>${this.options.cancel ? '<!--' : ''}
|
|
2155
2164
|
`
|
|
@@ -2162,24 +2171,30 @@ class WebsyForm {
|
|
|
2162
2171
|
</form>
|
|
2163
2172
|
<div id="${this.elementId}_validationFail" class="websy-validation-failure"></div>
|
|
2164
2173
|
`
|
|
2165
|
-
if (this.options.useRecaptcha === true) {
|
|
2166
|
-
html += `
|
|
2167
|
-
<div id='${this.elementId}_recaptcha'></div>
|
|
2168
|
-
`
|
|
2169
|
-
}
|
|
2170
2174
|
el.innerHTML = html
|
|
2171
2175
|
this.processComponents(componentsToProcess, () => {
|
|
2172
2176
|
if (this.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {
|
|
2173
|
-
|
|
2177
|
+
this.recaptchaReady()
|
|
2174
2178
|
}
|
|
2175
2179
|
})
|
|
2176
2180
|
}
|
|
2177
2181
|
}
|
|
2178
2182
|
submitForm () {
|
|
2179
2183
|
const formEl = document.getElementById(`${this.elementId}Form`)
|
|
2184
|
+
const buttonEl = formEl.querySelector('button.websy-btn.submit')
|
|
2185
|
+
const recaptchErrEl = document.getElementById(`${this.elementId}_recaptchaError`)
|
|
2180
2186
|
if (formEl.reportValidity() === true) {
|
|
2187
|
+
if (buttonEl) {
|
|
2188
|
+
buttonEl.setAttribute('disabled', true)
|
|
2189
|
+
}
|
|
2181
2190
|
this.checkRecaptcha().then(result => {
|
|
2182
|
-
if (
|
|
2191
|
+
if (buttonEl) {
|
|
2192
|
+
buttonEl.removeAttribute('disabled')
|
|
2193
|
+
}
|
|
2194
|
+
if (result === true) {
|
|
2195
|
+
if (recaptchErrEl) {
|
|
2196
|
+
recaptchErrEl.classList.add('websy-hidden')
|
|
2197
|
+
}
|
|
2183
2198
|
const formData = new FormData(formEl)
|
|
2184
2199
|
const data = {}
|
|
2185
2200
|
const temp = new FormData(formEl)
|
|
@@ -2199,6 +2214,7 @@ class WebsyForm {
|
|
|
2199
2214
|
// this.render()
|
|
2200
2215
|
formEl.reset()
|
|
2201
2216
|
}
|
|
2217
|
+
buttonEl.removeAttribute('disabled')
|
|
2202
2218
|
this.options.onSuccess.call(this, result)
|
|
2203
2219
|
}, err => {
|
|
2204
2220
|
console.log('Error submitting form data:', err)
|
|
@@ -2215,7 +2231,12 @@ class WebsyForm {
|
|
|
2215
2231
|
}
|
|
2216
2232
|
}
|
|
2217
2233
|
else {
|
|
2218
|
-
|
|
2234
|
+
if (buttonEl) {
|
|
2235
|
+
buttonEl.removeAttribute('disabled')
|
|
2236
|
+
}
|
|
2237
|
+
if (recaptchErrEl) {
|
|
2238
|
+
recaptchErrEl.classList.remove('websy-hidden')
|
|
2239
|
+
}
|
|
2219
2240
|
}
|
|
2220
2241
|
})
|
|
2221
2242
|
}
|