Skip to content

Commit

Permalink
Add reCaptcha data to config file
Browse files Browse the repository at this point in the history
  • Loading branch information
conache committed Jul 22, 2024
1 parent 198ed87 commit 7a14130
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@ export default {
}
},
],
recaptchaSecret: process.env.RECAPTCHA_SECRET
reCaptcha: {
siteKey: process.env.RECAPTCHA_SITE_KEY,
secretKey: process.env.RECAPTCHA_SECRET_KEY
}
}
3 changes: 2 additions & 1 deletion faucet.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ app.get('/config.json', async (req, res) => {
project.sample = sample
project.blockchains = conf.blockchains.map(x => x.name)
project.addressPrefix = conf.blockchains[0].sender.option.prefix
project.reCaptchaSiteKey = conf.reCaptcha.siteKey
res.send(project);
})

Expand Down Expand Up @@ -235,7 +236,7 @@ app.listen(conf.port, () => {
})

async function getRecaptchaVerification(token) {
const secret = conf.recaptchaSecret;
const secret = conf.reCaptcha.secretKey;
console.log("Fetching recaptcha verification:", `https://www.google.com/recaptcha/api/siteverify?secret=${secret}&response=${token}`)
const response = await fetch(`https://www.google.com/recaptcha/api/siteverify?secret=${secret}&response=${token}`, {
method: 'POST',
Expand Down
5 changes: 3 additions & 2 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@
conf: {},
balance: {},
ethAddr: '0xxxx',
reCapchaSiteKey: '6LeGtRQqAAAAAK7tMpJVYzioy14_m81K-WvLjZba',
reCapchaSiteKey: '',
}
},
created() {
fetch("/config.json").then(response => response.json()).then(data => {
this.conf = data
this.chain = data.blockchains[0]
this.reCapchaSiteKey = data.reCaptchaSiteKey
// this.placeholder = `Input an address (e.g.: ${data.sample[this.chain]}) to received tokens`
this.onChange();
});
Expand All @@ -103,7 +104,7 @@
initReCaptcha: function() {
var self = this;
setTimeout(function() {
if(typeof grecaptcha === 'undefined') {
if(typeof grecaptcha === 'undefined' || !self.reCapchaSiteKey) {
self.initReCaptcha();
}
else {
Expand Down

0 comments on commit 7a14130

Please sign in to comment.