Last active
April 7, 2018 16:49
-
-
Save MagRelo/b155fcee3fd50cf738bf4b80b466e4a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sigUtil = require('eth-sig-util') | |
app.post('/api/message', (req, res) => { | |
const messageData = req.body.messageData | |
const signature = req.body.signature | |
// recover the public key | |
const publicKey = sigUtil.recoverTypedSignature({ | |
data: messageData, | |
sig: signature | |
}) | |
// check if public key is on the approved list | |
const approvedPublicKeys = [ | |
'0xdf396910e694f7De31eF88d0090F2A4333ffcCF3', | |
'0x106F681949E222D57A165cD85685E3bD9975b973' | |
] | |
if(approvedPublicKeys.indexOf(publicKey) > -1){ | |
// save the vote | |
mongoDb.messages.save(messageData) | |
} | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment