From 862295390593cd946d14d1ade59f914f7a8ec71d Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Sun, 28 Jun 2020 15:51:26 +0200 Subject: [PATCH] Fix Reddit proof --- assets/scripts.js | 10 ++-------- server/verifyReddit.php | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 server/verifyReddit.php diff --git a/assets/scripts.js b/assets/scripts.js index d9892a7..2db5ebb 100644 --- a/assets/scripts.js +++ b/assets/scripts.js @@ -333,7 +333,7 @@ async function verifyProof(url, fingerprint) { match = url.match(/https:\/\/www.reddit.com\/user\/(.*)\/comments\/(.*)\/(.*)\//); output.display = match[1]; output.url = `https://www.reddit.com/user/${match[1]}`; - output.proofUrlFetch = url.replace(/\/[a-zA-Z0-9_]*\/$/, ".json"); + output.proofUrlFetch = `/server/verifyReddit.php?user=${match[1]}&comment=${match[2]}&fp=${fingerprint}`; try { response = await fetch(output.proofUrlFetch, { headers: { @@ -345,13 +345,7 @@ async function verifyProof(url, fingerprint) { throw new Error('Response failed: ' + response.status); } json = await response.json(); - console.log(json); - reVerify = new RegExp(`Verifying my OpenPGP key: openpgp4fpr:${fingerprint}`); - json.Answer.forEach((item, i) => { - if (reVerify.test(item.data)) { - output.isVerified = true; - } - }); + output.isVerified = json.verified; } catch (e) { } finally { return output; diff --git a/server/verifyReddit.php b/server/verifyReddit.php new file mode 100644 index 0000000..ea3d47e --- /dev/null +++ b/server/verifyReddit.php @@ -0,0 +1,38 @@ +