fixing jira issue IOTS-368

revert-dabc3590
Hasunie 8 years ago
parent 8bd06c60f2
commit e186ef6bb3

@ -18,7 +18,7 @@ under the License. --}}
{{#zone "accessControl"}} {{#zone "accessControl"}}
{{ {{
unit "mdm.unit.enrollments.access-control" unit "mdm.unit.enrollments.access-control"
allowedPlatform = "Windows Phone" allowedPlatform = ["Windows Phone", "Windows"]
currentPage = "invoke-agent" currentPage = "invoke-agent"
nextPage = "login-agent" nextPage = "login-agent"
}} }}

@ -29,11 +29,7 @@ function onRequest(context) {
parser.getResult(); parser.getResult();
var userAgentPlatform = parser.getOS()["name"]; var userAgentPlatform = parser.getOS()["name"];
if (userAgentPlatform != context.unit.params["allowedPlatform"]) { if (context.unit.params["allowedPlatform"].indexOf(userAgentPlatform) !== -1) {
// if userAgentPlatform is not allowed
log.error("platform not allowed");
response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request");
} else {
var lastPage = context.unit.params["lastPage"]; var lastPage = context.unit.params["lastPage"];
var nextPage = context.unit.params["nextPage"]; var nextPage = context.unit.params["nextPage"];
var currentPage = context.unit.params["currentPage"]; var currentPage = context.unit.params["currentPage"];
@ -44,9 +40,7 @@ function onRequest(context) {
if (!session.get("lastAccessedPage")) { if (!session.get("lastAccessedPage")) {
// meaning a middle page is accessed at first // meaning a middle page is accessed at first
response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request");
} else if (!(session.get("lastAccessedPage") == currentPage) && } else if (!(session.get("lastAccessedPage") == currentPage) && !(session.get("lastAccessedPage") == lastPage) && !(session.get("lastAccessedPage") == nextPage)) {
!(session.get("lastAccessedPage") == lastPage) &&
!(session.get("lastAccessedPage") == nextPage)) {
response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request");
} else if (currentPage) { } else if (currentPage) {
// if currentPage is set, update lastAccessedPage as currentPage // if currentPage is set, update lastAccessedPage as currentPage
@ -57,8 +51,7 @@ function onRequest(context) {
if (!session.get("lastAccessedPage")) { if (!session.get("lastAccessedPage")) {
// this means the last page is accessed at first // this means the last page is accessed at first
response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request");
} else if (!(session.get("lastAccessedPage") == currentPage) && } else if (!(session.get("lastAccessedPage") == currentPage) && !(session.get("lastAccessedPage") == lastPage)) {
!(session.get("lastAccessedPage") == lastPage)) {
response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request");
} else if (currentPage) { } else if (currentPage) {
// if currentPage is set, update lastAccessedPage as currentPage // if currentPage is set, update lastAccessedPage as currentPage
@ -69,11 +62,15 @@ function onRequest(context) {
// if currentPage is set, update lastAccessedPage as currentPage // if currentPage is set, update lastAccessedPage as currentPage
session.put("lastAccessedPage", currentPage); session.put("lastAccessedPage", currentPage);
} }
} else {
// if userAgentPlatform is not allowed
log.error("platform not allowed");
response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request");
} }
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("last-accessed-page = " + session.get("lastAccessedPage") + log.debug("last-accessed-page = " + session.get("lastAccessedPage") +
" : " + "session-id = " + session.getId()); " : " + "session-id = " + session.getId());
} }
return context; return context;
} }
Loading…
Cancel
Save