Fixed to allow users to edit their own entries

This commit is contained in:
nannal 2020-11-18 23:26:50 +02:00
parent 9914018163
commit 55822c2991
2 changed files with 3 additions and 7 deletions

View File

@ -25,14 +25,12 @@ app.get('/account/:username', function (req, res) {
})
app.post('/submit', function (req, res) {
console.log(req.body)
list.writeUser(req.body).then(r => {
res.send(JSON.stringify(r))
})
})
app.post('/approve', function (req, res) {
console.log(req.body)
list.approveUser(req.body).then(r => {
res.send(JSON.stringify(r))
})

View File

@ -20,7 +20,6 @@ async function verifyMsg (obj) {
if (sender.keys)
for (let i = 0; i < sender.keys.length; i++)
allowedPubKeys.push(sender.keys[i].pub)
console.log(allowedPubKeys)
for (let i = 0; i < allowedPubKeys.length; i++) {
var bufferHash = Buffer.from(obj.hash, 'hex')
var b58sign = bs58.decode(obj.signature)
@ -44,7 +43,6 @@ list = {
writeUser: async (obj) => {
ver = await verifyMsg(obj)
if (ver == true) {
console.log(obj)
limitedObj={
user: obj.user,
status: obj.status,
@ -56,10 +54,11 @@ list = {
}
res = await mongo.get("list","list",{"user": limitedObj.user})
if (res.length > 0 ){
if (limitedObj.sender == res.sender){
if (limitedObj.sender == res[0].sender){
mongo.update("list","list",{"user": limitedObj.user}, limitedObj)
} else {
return {"Message": "This user is controlled by "+res.sender+" contact them to modify this entry, in an emergency contant nannal"}
console.log(res[0])
return {"Message": "This user is controlled by "+res[0].sender+" contact them to modify this entry, in an emergency contant nannal"}
}
} else {
@ -75,7 +74,6 @@ list = {
approveUser: async (obj) => {
ver = await verifyMsg(obj)
if (ver == true) {
console.log(obj)
limitedObj={
user: obj.user,
sender: obj.sender,