summaryrefslogtreecommitdiffstats
path: root/server/authentication.js
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2019-01-27 18:16:27 +0200
committerLauri Ojansivu <x@xet7.org>2019-01-27 18:16:27 +0200
commitbe03a191c4321c2f80116c0ee1ae6c826d882535 (patch)
tree530d1d7db47d30456106b6f3ea1d54d356303c07 /server/authentication.js
parentcf7d3b5a7ea7043eb454f7c3330f2c316957b3dc (diff)
downloadwekan-be03a191c4321c2f80116c0ee1ae6c826d882535.tar.gz
wekan-be03a191c4321c2f80116c0ee1ae6c826d882535.tar.bz2
wekan-be03a191c4321c2f80116c0ee1ae6c826d882535.zip
- Try to have some progress on Wekan Sandstorm API. I did not get it fully working yet.
Thanks to xet7.
Diffstat (limited to 'server/authentication.js')
-rw-r--r--server/authentication.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/server/authentication.js b/server/authentication.js
index 4d3cc53e..d0d71e4d 100644
--- a/server/authentication.js
+++ b/server/authentication.js
@@ -17,6 +17,27 @@ Meteor.startup(() => {
Authentication.checkUserId = function (userId) {
if (userId === undefined) {
+ // Monkey patch to work around the problem described in
+ // https://github.com/sandstorm-io/meteor-accounts-sandstorm/pull/31
+ const _httpMethods = HTTP.methods;
+ HTTP.methods = (newMethods) => {
+ Object.keys(newMethods).forEach((key) => {
+ if (newMethods[key].auth) {
+ newMethods[key].auth = function() {
+ const sandstormID = this.req.headers['x-sandstorm-user-id'];
+ const user = Meteor.users.findOne({'services.sandstorm.id': sandstormID});
+ if (user) {
+ userId = user._id;
+ }
+ //return user && user._id;
+ };
+ }
+ });
+ _httpMethods(newMethods);
+ };
+ }
+
+ if (userId === undefined) {
const error = new Meteor.Error('Unauthorized', 'Unauthorized');
error.statusCode = 401;
throw error;