RIFT-14989: Login fixes for Accounts and RO Config pages

Signed-off-by: Laurence Maultsby <laurence.maultsby@riftio.com>
diff --git a/skyquake/framework/core/api_utils/utils.js b/skyquake/framework/core/api_utils/utils.js
index 163769a..0d1990c 100644
--- a/skyquake/framework/core/api_utils/utils.js
+++ b/skyquake/framework/core/api_utils/utils.js
@@ -1,5 +1,5 @@
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
@@ -233,5 +233,5 @@
 
 	sendSuccessResponse: sendSuccessResponse,
 
-	passThroughConstructor: passThroughConstructor
+    passThroughConstructor: passThroughConstructor
 };
diff --git a/skyquake/framework/core/modules/routes/configuration.js b/skyquake/framework/core/modules/routes/configuration.js
index 3a686f0..b789ff0 100644
--- a/skyquake/framework/core/modules/routes/configuration.js
+++ b/skyquake/framework/core/modules/routes/configuration.js
@@ -1,6 +1,6 @@
 
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +18,7 @@
  */
 
 /**
- * Node configuration routes module. 
+ * Node configuration routes module.
  * Provides a RESTful API to provide configuration
  * details such as api_server.
  * @module framework/core/modules/routes/configuration
@@ -30,6 +30,9 @@
 var configurationAPI = require('../api/configuration');
 var Router = require('express').Router();
 var utils = require('../../api_utils/utils');
+var CONSTANTS = require('../../api_utils/constants.js');
+var request = require('request');
+var _ = require('lodash');
 
 Router.use(bodyParser.json());
 Router.use(cors());
@@ -48,9 +51,43 @@
 Router.get('/server-configuration', cors(), function(req, res) {
     configurationAPI.get(req).then(function(data) {
         utils.sendSuccessResponse(data, res);
-	}, function(error) {
-		utils.sendErrorResponse(error, res);
-	});
+    }, function(error) {
+        utils.sendErrorResponse(error, res);
+    });
 });
 
+Router.get('/check-auth', function(req, res) {
+    console.log('testing auth')
+    var api_server = req.query["api_server"];
+    var uri = utils.confdPort(api_server) + '/api/config/';
+
+    checkAuth(uri, req).then(function(data) {
+        utils.sendSuccessResponse(data, res);
+    }, function(error) {
+        utils.sendErrorResponse(error, res);
+    });
+});
+
+function checkAuth(uri, req){
+    return new Promise(function(resolve, reject) {
+        request({
+            uri: uri,
+            method: 'GET',
+            headers: _.extend({}, {
+                'Authorization': req.get('Authorization'),
+                forever: CONSTANTS.FOREVER_ON,
+                rejectUnauthorized: false,
+            })
+        }, function(error, response, body) {
+            console.log(arguments)
+            if( response.statusCode == 401) {
+                reject({statusCode: 401, error: response.body});
+            } else {
+                resolve({statusCode:200, data:response.body})
+            }
+        });
+    });
+}
+
+
 module.exports = Router;
diff --git a/skyquake/framework/utils/utils.js b/skyquake/framework/utils/utils.js
index d08fe5f..7442027 100644
--- a/skyquake/framework/utils/utils.js
+++ b/skyquake/framework/utils/utils.js
@@ -1,5 +1,5 @@
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,7 +20,7 @@
 var $ = require('jquery');
 var rw = require('utils/rw.js');
 var API_SERVER = rw.getSearchParams(window.location).api_server;
-var NODE_PORT = 3000;
+let NODE_PORT = require('utils/rw.js').getSearchParams(window.location).api_port || ((window.location.protocol == 'https:') ? 8443 : 8000);
 var SockJS = require('sockjs-client');
 
 var Utils = {};
@@ -188,9 +188,20 @@
     var AuthBase64 = btoa(username + ":" + password);
     window.sessionStorage.setItem("auth", AuthBase64);
     self.detectInactivity();
-    if (cb) {
-        cb();
-    }
+    $.ajax({
+            url: '//' + window.location.hostname + ':' + NODE_PORT + '/check-auth?api_server=' + API_SERVER,
+            type: 'GET',
+            beforeSend: Utils.addAuthorizationStub,
+            success: function(data) {
+              //console.log("LoggingSource.getLoggingConfig success call. data=", data);
+                if (cb) {
+                    cb();
+                };
+            },
+            error: function(data) {
+                Utils.clearAuthentication();
+            }
+          });
 }
 Utils.clearAuthentication = function(callback) {
     var self = this;