summaryrefslogtreecommitdiffstats
path: root/models/export.js
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2019-01-22 17:33:27 +0200
committerLauri Ojansivu <x@xet7.org>2019-01-22 17:33:27 +0200
commit46a468b06dd5d4ca2338140bb2fd32958ccef85f (patch)
tree9a7656c0fa92c0895c25d958764f090c74d0c129 /models/export.js
parent8d4eef66493f464035616fec7ac8b2f14720ce57 (diff)
parent1b445ad789a41d97b7cf4e16af35f52ae0be694b (diff)
downloadwekan-46a468b06dd5d4ca2338140bb2fd32958ccef85f.tar.gz
wekan-46a468b06dd5d4ca2338140bb2fd32958ccef85f.tar.bz2
wekan-46a468b06dd5d4ca2338140bb2fd32958ccef85f.zip
Merge branch 'edge' into meteor-1.8
Diffstat (limited to 'models/export.js')
-rw-r--r--models/export.js21
1 files changed, 15 insertions, 6 deletions
diff --git a/models/export.js b/models/export.js
index 62d2687a..50971c88 100644
--- a/models/export.js
+++ b/models/export.js
@@ -6,25 +6,34 @@ if (Meteor.isServer) {
// `ApiRoutes.path('boards/export', boardId)``
// on the client instead of copy/pasting the route path manually between the
// client and the server.
- /*
- * This route is used to export the board FROM THE APPLICATION.
- * If user is already logged-in, pass loginToken as param "authToken":
- * '/api/boards/:boardId/export?authToken=:token'
+ /**
+ * @operation export
+ * @tag Boards
+ *
+ * @summary This route is used to export the board.
+ *
+ * @description If user is already logged-in, pass loginToken as param
+ * "authToken": '/api/boards/:boardId/export?authToken=:token'
*
* See https://blog.kayla.com.au/server-side-route-authentication-in-meteor/
* for detailed explanations
+ *
+ * @param {string} boardId the ID of the board we are exporting
+ * @param {string} authToken the loginToken
*/
JsonRoutes.add('get', '/api/boards/:boardId/export', function(req, res) {
const boardId = req.params.boardId;
let user = null;
- // todo XXX for real API, first look for token in Authentication: header
- // then fallback to parameter
+
const loginToken = req.query.authToken;
if (loginToken) {
const hashToken = Accounts._hashLoginToken(loginToken);
user = Meteor.users.findOne({
'services.resume.loginTokens.hashedToken': hashToken,
});
+ } else {
+ Authentication.checkUserId(req.userId);
+ user = Users.findOne({ _id: req.userId, isAdmin: true });
}
const exporter = new Exporter(boardId);