summaryrefslogtreecommitdiffstats
path: root/models/users.js
diff options
context:
space:
mode:
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);