Verified Commit 3b14ca53 authored by Rigel Kent's avatar Rigel Kent
Browse files

simple-get instead of request, small refactoring

parent 4e432f97
var _request = require("request")
const request = function(options) {
return new Promise((resolve,reject) => {
_request(options, (error, response, body) => {
if (response) {
return resolve(response)
}
if (error) {
return reject(error)
}
})
})
}
const get = require("simple-get")
async function register({
registerHook,
......@@ -55,11 +42,7 @@ module.exports = {
async function verifyCaptcha (result, params, settingsManager) {
// g-recaptcha-response is the key that browser will generate upon form submit.
// if its blank or null means user has not selected the captcha, so return the error.
if (
params.body["g-recaptcha-response"] === undefined ||
params.body["g-recaptcha-response"] === "" ||
params.body["g-recaptcha-response"] === null
) {
if (!params.body["g-recaptcha-response"]) {
return { allowed: false, errorMessage: "Captcha wasn't filled" }
}
......@@ -75,7 +58,7 @@ async function verifyCaptcha (result, params, settingsManager) {
"&remoteip=" +
params.connection.remoteAddress
return await request(verificationUrl, (error, response, body) => {
return get(verificationUrl, function (err, res, body) {
body = JSON.parse(body)
if (body.success !== undefined && !body.success) {
return { allowed: false, errorMessage: "Wrong captcha" }
......
......@@ -931,6 +931,14 @@
"integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=",
"dev": true
},
"decompress-response": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz",
"integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==",
"requires": {
"mimic-response": "^2.0.0"
}
},
"define-property": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz",
......@@ -2552,6 +2560,11 @@
"integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==",
"dev": true
},
"mimic-response": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.0.0.tgz",
"integrity": "sha512-8ilDoEapqA4uQ3TwS0jakGONKXVJqpy+RpM+3b7pLdOjghCrEiGp9SRkFbUHAmZW9vdnrENWHjaweIoTIJExSQ=="
},
"minimalistic-assert": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
......@@ -2806,7 +2819,6 @@
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true,
"requires": {
"wrappy": "1"
}
......@@ -3333,6 +3345,21 @@
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=",
"dev": true
},
"simple-concat": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz",
"integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY="
},
"simple-get": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.0.tgz",
"integrity": "sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==",
"requires": {
"decompress-response": "^4.2.0",
"once": "^1.3.1",
"simple-concat": "^1.0.0"
}
},
"snapdragon": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz",
......@@ -4000,8 +4027,7 @@
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
},
"xtend": {
"version": "4.0.2",
......
......@@ -16,7 +16,8 @@
"assets/style.css"
],
"dependencies": {
"loadjs": "^4.0.1"
"loadjs": "^4.0.1",
"simple-get": "^3.1.0"
},
"devDependencies": {
"@purtuga/esm-webpack-plugin": "^1.1.1",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment