refactor(oauth): put script tag in body (#6958)

This commit is contained in:
Luc Guinchard
2021-02-25 00:07:49 +01:00
committed by GitHub
parent 4db2edcad2
commit 482dea8f53

View File

@@ -4,8 +4,6 @@
<title>Swagger UI: OAuth2 Redirect</title> <title>Swagger UI: OAuth2 Redirect</title>
</head> </head>
<body> <body>
</body>
</html>
<script> <script>
'use strict'; 'use strict';
function run () { function run () {
@@ -20,15 +18,15 @@
qp = location.search.substring(1); qp = location.search.substring(1);
} }
arr = qp.split("&") arr = qp.split("&");
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';}) arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
qp = qp ? JSON.parse('{' + arr.join() + '}', qp = qp ? JSON.parse('{' + arr.join() + '}',
function (key, value) { function (key, value) {
return key === "" ? value : decodeURIComponent(value) return key === "" ? value : decodeURIComponent(value);
} }
) : {} ) : {};
isValid = qp.state === sentState isValid = qp.state === sentState;
if (( if ((
oauth2.auth.schema.get("flow") === "accessCode" || oauth2.auth.schema.get("flow") === "accessCode" ||
@@ -49,7 +47,7 @@
oauth2.auth.code = qp.code; oauth2.auth.code = qp.code;
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl}); oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
} else { } else {
let oauthErrorMsg let oauthErrorMsg;
if (qp.error) { if (qp.error) {
oauthErrorMsg = "["+qp.error+"]: " + oauthErrorMsg = "["+qp.error+"]: " +
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") + (qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
@@ -73,3 +71,5 @@
run(); run();
}); });
</script> </script>
</body>
</html>