-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthRedirect.html
More file actions
69 lines (61 loc) · 2.13 KB
/
authRedirect.html
File metadata and controls
69 lines (61 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html>
<head>
<title>AppAuthJS Redirect</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<noscript>
<h1>Please enable JavaScript to use CheckMyTrip app</h1>
</noscript>
<script type="text/javascript">
// Function to extract params from URL (Extracts key value pairs with '=' in between which comes after ? # &)
var getParams = function (url) {
var regex = /[?#&]([^=#]+)=([^&#?]*)/g;
var decodedUrl = decodeURIComponent(url);
var params = {};
var match = regex.exec(decodedUrl);
while (match) {
params[match[1]] = match[2];
match = regex.exec(decodedUrl);
}
return params;
}
// Function to build the redirect URL
var buildURL = function (path, route, paramKeys, params) {
var finalPath = path + "?" + "ST=" + params.ST + "#" + route + "?";
var isFirstParamAdded = false;
for (var i = 0; i < paramKeys.length; i++) {
if (params[paramKeys[i]]) {
if (isFirstParamAdded) {
finalPath = finalPath + "&";
}
finalPath = finalPath + paramKeys[i] + "=" + params[paramKeys[i]];
isFirstParamAdded = true;
}
}
return finalPath;
}
var AUTH_REDIRECT_ROUTE = 'auth-redirect';
var POST_LOGOUT_REDIRECT_ROUTE = 'logout-redirect';
var params = getParams(window.location.href);
var path = "/mobile/";
params.ST = "NCMTDEMO";
params.page = "authredirect";
params.feature = "openid";
var redirectRoute = "";
if (params.page === 'authredirect') {
redirectRoute = buildURL(path, AUTH_REDIRECT_ROUTE, ["feature", "code", "state", "access_token", "id_token"], params);
} else if (params.page === 'authlogout') {
redirectRoute = buildURL(path, POST_LOGOUT_REDIRECT_ROUTE, ["feature"], params);
} else {
redirectRoute = buildURL(path, "", [], params);
}
var origin = "https://ncebpm1195aph01.etv.nce.amadeus.net";
var fullPath = origin + redirectRoute;
// window.location.assign(redirectRoute);
debugger
window.location.href = fullPath;
</script>
</head>
<body>
</body>
</html>