summaryrefslogtreecommitdiffstats
path: root/models/users.js
diff options
context:
space:
mode:
authorguillaume <guillaume.cassou@supinfo.com>2018-07-24 18:09:30 +0200
committerguillaume <guillaume.cassou@supinfo.com>2018-07-24 18:09:30 +0200
commit6173a7338135c87321be909482ff356d32977de6 (patch)
tree1de96a5b145463651d335cd17e30a8d62ce6e6b5 /models/users.js
parentdafe1e39a53543a20505705185c84053ae0a1918 (diff)
downloadwekan-6173a7338135c87321be909482ff356d32977de6.tar.gz
wekan-6173a7338135c87321be909482ff356d32977de6.tar.bz2
wekan-6173a7338135c87321be909482ff356d32977de6.zip
enable/disable api with env var
Diffstat (limited to 'models/users.js')
-rw-r--r--models/users.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/models/users.js b/models/users.js
index 9d859664..9b070c43 100644
--- a/models/users.js
+++ b/models/users.js
@@ -622,9 +622,20 @@ if (Meteor.isServer) {
});
}
-
// USERS REST API
if (Meteor.isServer) {
+ // Middleware which checks that API is enabled.
+ JsonRoutes.Middleware.use(function (req, res, next) {
+ const api = req.url.search('api');
+ if (api === 1 && process.env.WITH_API === 'true' || api === -1){
+ return next();
+ }
+ else {
+ res.writeHead(301, {Location: '/'});
+ return res.end();
+ }
+ });
+
JsonRoutes.add('GET', '/api/user', function(req, res) {
try {
Authentication.checkLoggedIn(req.userId);