Fixing issue: EMM-1537

revert-70aa11f8
amalhub 8 years ago
parent 406d49ad61
commit 8b4649b4e5

@ -51,7 +51,12 @@ if (uriMatcher.match("/{context}/api/operation/paginate")) {
} else { } else {
response["status"] = restAPIResponse["status"]; response["status"] = restAPIResponse["status"];
if (restAPIResponse["responseText"]) { if (restAPIResponse["responseText"]) {
response["content"] = parse(restAPIResponse["responseText"]); var responseText = "";
try {
response["content"] = parse(restAPIResponse["responseText"]);
} catch (e) {
responseText = restAPIResponse["responseText"];
}
} }
} }
} }

@ -45,12 +45,13 @@ var invokers = function () {
* If the token pair is not set in the session, this will return null. * If the token pair is not set in the session, this will return null.
*/ */
privateMethods.getAccessToken = function () { privateMethods.getAccessToken = function () {
var tokenPair = session.get(constants["TOKEN_PAIR"]); if (session) {
if (tokenPair) { var tokenPair = session.get(constants["TOKEN_PAIR"]);
return parse(tokenPair)["accessToken"]; if (tokenPair) {
} else { return parse(tokenPair)["accessToken"];
return null; }
} }
return null;
}; };
/** /**
@ -80,9 +81,10 @@ var invokers = function () {
if (devicemgtProps["isOAuthEnabled"]) { if (devicemgtProps["isOAuthEnabled"]) {
var accessToken = privateMethods.getAccessToken(); var accessToken = privateMethods.getAccessToken();
if (!accessToken) { if (accessToken == null) {
userModule.logout(function () { userModule.logout(function () {
response.sendRedirect(devicemgtProps["appContext"] + "login"); response.sendRedirect(devicemgtProps["appContext"] + "login");
return responseCallback({"status": 401, "responseText" : "Session expired!"});
}); });
} else { } else {
xmlHttpRequest.setRequestHeader(constants["AUTHORIZATION_HEADER"], xmlHttpRequest.setRequestHeader(constants["AUTHORIZATION_HEADER"],

Loading…
Cancel
Save