mirror of
https://github.com/Expand-sys/ccashfrontend
synced 2025-12-18 15:42:14 +11:00
marketplace fixed, forgot about implementing the sending money on purchase
This commit is contained in:
parent
cb65c3bf24
commit
53ac35d487
3 changed files with 13 additions and 3 deletions
2
index.js
2
index.js
|
|
@ -300,6 +300,7 @@ app.post('/sendfunds', async function(req, res){
|
||||||
|
|
||||||
app.post('/register', async function(req, res){
|
app.post('/register', async function(req, res){
|
||||||
var {name, password, password2} = req.body;
|
var {name, password, password2} = req.body;
|
||||||
|
|
||||||
let checkuser = await got(process.env.BANKAPIURL+'BankF/contains/'+name)
|
let checkuser = await got(process.env.BANKAPIURL+'BankF/contains/'+name)
|
||||||
checkuser = JSON.parse(checkuser.body).value
|
checkuser = JSON.parse(checkuser.body).value
|
||||||
let errors = [];
|
let errors = [];
|
||||||
|
|
@ -355,6 +356,7 @@ app.post('/login', async function(req, res){
|
||||||
} catch(err){
|
} catch(err){
|
||||||
console.log(err)
|
console.log(err)
|
||||||
}
|
}
|
||||||
|
req.session.password = password
|
||||||
if(adminTest.body.value == undefined){
|
if(adminTest.body.value == undefined){
|
||||||
res.redirect('/')
|
res.redirect('/')
|
||||||
}else{
|
}else{
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ router.get('/marketdash', ensureAuthenticated, function(req,res){
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
setTimeout(500);
|
|
||||||
res.render('marketdash',{
|
res.render('marketdash',{
|
||||||
user:req.session.user,
|
user:req.session.user,
|
||||||
admin:req.session.admin,
|
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){
|
router.post('/:id/buy',async function(req, res){
|
||||||
Listing.findOne({_id: req.params.id}, async function(err, listing){
|
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()
|
let inventory = await Inventory.findOne({user:req.session.user}).exec()
|
||||||
if(inventory == null){
|
if(inventory == null){
|
||||||
|
|
@ -208,7 +207,15 @@ router.post('/:id/buy',async function(req, res){
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Listing.findOneAndRemove({_id:req.params.id}).exec()
|
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")
|
res.redirect("/marketplace/marketdash")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ block content
|
||||||
br
|
br
|
||||||
br
|
br
|
||||||
label Amount:
|
label Amount:
|
||||||
|
br
|
||||||
input.form-control-lg.shadow(type="number" min="0" name="amount")
|
input.form-control-lg.shadow(type="number" min="0" name="amount")
|
||||||
br
|
br
|
||||||
br
|
br
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue