Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 

54 рядки
1.8 KiB

  1. <!doctype html>
  2. <html lang="en-US">
  3. <body onload="run()">
  4. </body>
  5. </html>
  6. <script>
  7. 'use strict';
  8. function run () {
  9. var oauth2 = window.opener.swaggerUIRedirectOauth2;
  10. var sentState = oauth2.state;
  11. var redirectUrl = oauth2.redirectUrl;
  12. var isValid, qp, arr;
  13. qp = (window.location.hash || location.search).substring(1);
  14. arr = qp.split("&")
  15. arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
  16. qp = qp ? JSON.parse('{' + arr.join() + '}',
  17. function (key, value) {
  18. return key === "" ? value : decodeURIComponent(value)
  19. }
  20. ) : {}
  21. isValid = qp.state === sentState
  22. if (oauth2.auth.schema.get("flow") === "accessCode" && !oauth2.auth.code) {
  23. if (!isValid) {
  24. oauth2.errCb({
  25. authId: oauth2.auth.name,
  26. source: "auth",
  27. level: "warning",
  28. message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
  29. });
  30. }
  31. if (qp.code) {
  32. delete oauth2.state;
  33. oauth2.auth.code = qp.code;
  34. oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
  35. } else {
  36. oauth2.errCb({
  37. authId: oauth2.auth.name,
  38. source: "auth",
  39. level: "error",
  40. message: "Authorization failed: no accessCode received from the server"
  41. });
  42. }
  43. } else {
  44. oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
  45. }
  46. window.close();
  47. }
  48. </script>