Merge branch 'master' into v1.1
[osm/UI.git] / skyquake / framework / core / api_utils / utils.js
index bd99fe1..5b17279 100644 (file)
@@ -217,32 +217,13 @@ var passThroughConstructor = function(app) {
        });
 }
 
-
-var testAuthentication = function(app) {
-    app.get('/check-auth', function(req, res) {
-        console.log('testing auth')
-        var api_server = req.query["api_server"];
-        var uri = confdPort(api_server) + '/api/config/';
-                new Promise(function(resolve, reject) {
-            request({
-                uri: uri,
-                method: 'GET',
-                headers: _.extend({}, CONSTANTS.HTTP_HEADERS.accept[type], {
-                    'Authorization': req.get('Authorization'),
-                    forever: CONSTANTS.FOREVER_ON,
-                    rejectUnauthorized: false,
-                })
-            }, function(error, response, body) {
-                if (validateResponse('Passthrough: ' + url, error, response, body, resolve, reject)) {
-                    resolve(JSON.parse(response.body))
-                };
-            });
-        }).then(function(data) {
-            res.send(data);
-        }, function(error) {
-                       res.send({'error': error, uri: uri})
-        });;
-    })
+var getPortForProtocol = function(protocol) {
+  switch (protocol) {
+    case 'http':
+      return 8000;
+    case 'https':
+      return 8443;
+  }
 }
 
 module.exports = {
@@ -263,5 +244,5 @@ module.exports = {
 
     passThroughConstructor: passThroughConstructor,
 
-    testAuthentication: testAuthentication
+    getPortForProtocol: getPortForProtocol
 };