From 7cfc72da995a247b77d24dca215e59af2f5ed5f0 Mon Sep 17 00:00:00 2001 From: Xavier Priour Date: Fri, 11 Dec 2015 19:20:19 +0100 Subject: export works but no authentication --- models/export.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/models/export.js b/models/export.js index bc7cb8f9..7be97986 100644 --- a/models/export.js +++ b/models/export.js @@ -1,8 +1,26 @@ /* global JsonRoutes */ -JsonRoutes.add('get', '/api/b/:id', function (req, res) { - const id = req.params.id; - const exporter = new Exporter(id); - JsonRoutes.sendResult(res, 200, exporter.build()); +if(Meteor.isServer) { + console.log(`userId is ${this.userId}`); + JsonRoutes.add('get', '/api/b/:id', function (req, res) { + const id = req.params.id; + const board = Boards.findOne(id); + //if(Meteor.userId() && allowIsBoardMember(Meteor.userId(), board)) { + const exporter = new Exporter(id); + JsonRoutes.sendResult(res, 200, exporter.build()); + //} else { + // // 403 = forbidden + // JsonRoutes.sendError(res, 403); + //} + }); +} + +Meteor.methods({ + exportBoard(boardId) { + const board = Boards.findOne(boardId); +// //if(Meteor.userId() && allowIsBoardMember(Meteor.userId(), board)) { + const exporter = new Exporter(boardId); + return exporter.build(); + } }); class Exporter { @@ -45,7 +63,7 @@ class Exporter { 'profile.avatarUrl': 1, }}; result.users = Users.find(byUserIds, userFields).fetch(); - + //return JSON.stringify(result); return result; } } -- cgit v1.2.3-1-g7c22