Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

61 linhas
2.0 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. if (/code|token|error/.test(window.location.hash)) {
  14. qp = window.location.hash.substring(1);
  15. } else {
  16. qp = location.search.substring(1);
  17. }
  18. arr = qp.split("&")
  19. arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
  20. qp = qp ? JSON.parse('{' + arr.join() + '}',
  21. function (key, value) {
  22. return key === "" ? value : decodeURIComponent(value)
  23. }
  24. ) : {}
  25. isValid = qp.state === sentState
  26. if ((
  27. oauth2.auth.schema.get("flow") === "accessCode"||
  28. oauth2.auth.schema.get("flow") === "authorizationCode"
  29. ) && !oauth2.auth.code) {
  30. if (!isValid) {
  31. oauth2.errCb({
  32. authId: oauth2.auth.name,
  33. source: "auth",
  34. level: "warning",
  35. message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
  36. });
  37. }
  38. if (qp.code) {
  39. delete oauth2.state;
  40. oauth2.auth.code = qp.code;
  41. oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
  42. } else {
  43. oauth2.errCb({
  44. authId: oauth2.auth.name,
  45. source: "auth",
  46. level: "error",
  47. message: "Authorization failed: no accessCode received from the server"
  48. });
  49. }
  50. } else {
  51. oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
  52. }
  53. window.close();
  54. }
  55. </script>