Revert "Revert "Merge branch 'master' of https://github.com/LukasNowy/SmartShopper""
This reverts commit 84afb3f32d
.
This commit is contained in:
@ -49,6 +49,7 @@ router.get('/logout', (req, res) => {
|
||||
|
||||
router.get('/dash', function(req, res, next) {
|
||||
console.log("Session: ", req.session.passport.user.token);
|
||||
console.log("User ID: " + req.session.passport.user.profile.id);
|
||||
if (req.session.passport.user.token) {
|
||||
res.render('index');
|
||||
} else {
|
||||
@ -61,7 +62,7 @@ router.get('/dash', function(req, res, next) {
|
||||
router.get("/myshoppinglists", async function(req, res, next) {
|
||||
try {
|
||||
//Get user id: req.session.passport.user.profile.id
|
||||
res.status(200).send(await postgres.getShoppinglistsAdmin("testuser"));
|
||||
res.status(200).send(await postgres.getShoppinglistsAdmin(req.session.passport.user.profile.id));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
@ -75,7 +76,7 @@ router.get("/myshoppinglists", async function(req, res, next) {
|
||||
router.get("/sharedshoppinglists", async function(req, res, next) {
|
||||
try {
|
||||
//Get user id: req.session.passport.user.profile.id
|
||||
res.status(200).send(await postgres.getShoppinglistsShared("testuser"));
|
||||
res.status(200).send(await postgres.getShoppinglistsShared(req.session.passport.user.profile.id));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
@ -84,4 +85,16 @@ router.get("/sharedshoppinglists", async function(req, res, next) {
|
||||
|
||||
});
|
||||
|
||||
//POST new shoppinglist
|
||||
|
||||
router.post("/shoppinglist", async function(req, res, next) {
|
||||
try {
|
||||
res.status(200).send(await postgres.newShoppinglist(req.body.name, req.body.description, req.session.passport.user.profile.id));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
Reference in New Issue
Block a user