summaryrefslogtreecommitdiffstats
path: root/models/export.js
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2018-07-27 07:12:29 +0200
committerBenjamin Tissoires <benjamin.tissoires@redhat.com>2019-01-22 15:14:01 +0100
commit26d7ba72aa85bd217fdb0e0e9ba16cdbdb9b4035 (patch)
tree159262ecf22ad851d37f190edc4ba157a2aa12bc /models/export.js
parent44e4df2492b95226f1297e7f556d61b1afaab714 (diff)
downloadwekan-26d7ba72aa85bd217fdb0e0e9ba16cdbdb9b4035.tar.gz
wekan-26d7ba72aa85bd217fdb0e0e9ba16cdbdb9b4035.tar.bz2
wekan-26d7ba72aa85bd217fdb0e0e9ba16cdbdb9b4035.zip
api: export board: allow authentication through generic authentication
This allows to retrieve the full export of the board from the API. When the board is big, retrieving individual cards is heavy for both the server and the number of requests. Allowing the API to directly call on export and then treat the data makes the whole process smoother.
Diffstat (limited to 'models/export.js')
-rw-r--r--models/export.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/models/export.js b/models/export.js
index fa4894d9..50971c88 100644
--- a/models/export.js
+++ b/models/export.js
@@ -10,7 +10,7 @@ if (Meteor.isServer) {
* @operation export
* @tag Boards
*
- * @summary This route is used to export the board **FROM THE APPLICATION**.
+ * @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'
@@ -24,14 +24,16 @@ if (Meteor.isServer) {
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);