marketplace fixed, forgot about implementing the sending money on purchase

This commit is contained in:
Expand-sys 2021-05-03 21:34:02 +10:00
parent cb65c3bf24
commit 53ac35d487
3 changed files with 13 additions and 3 deletions

View file

@ -300,6 +300,7 @@ app.post('/sendfunds', async function(req, res){
app.post('/register', async function(req, res){
var {name, password, password2} = req.body;
let checkuser = await got(process.env.BANKAPIURL+'BankF/contains/'+name)
checkuser = JSON.parse(checkuser.body).value
let errors = [];
@ -355,6 +356,7 @@ app.post('/login', async function(req, res){
} catch(err){
console.log(err)
}
req.session.password = password
if(adminTest.body.value == undefined){
res.redirect('/')
}else{

View file

@ -75,7 +75,7 @@ router.get('/marketdash', ensureAuthenticated, function(req,res){
}
})
}
setTimeout(500);
res.render('marketdash',{
user:req.session.user,
admin:req.session.admin,
@ -181,7 +181,6 @@ router.post('/:id/list',ensureAuthenticated, async function(req,res){
})
router.post('/:id/buy',async function(req, res){
Listing.findOne({_id: req.params.id}, async function(err, listing){
console.log(await Inventory.findOne({user:req.session.user}).exec())
let inventory = await Inventory.findOne({user:req.session.user}).exec()
if(inventory == null){
@ -208,7 +207,15 @@ router.post('/:id/buy',async function(req, res){
})
}
Listing.findOneAndRemove({_id:req.params.id}).exec()
transfer = got.post(process.env.BANKAPIURL+'BankF/sendfunds',{
json:{
a_name: req.session.user,
b_name: listing.seller,
amount: parseInt(listing.amount*listing.price),
attempt: req.session.password
},
responseType:'json'
})
res.redirect("/marketplace/marketdash")
})
})

View file

@ -25,6 +25,7 @@ block content
br
br
label Amount:
br
input.form-control-lg.shadow(type="number" min="0" name="amount")
br
br