Skip to content

Commit

Permalink
fix(oauth2): add fallback for case when window.opener is null
Browse files Browse the repository at this point in the history
  • Loading branch information
notpushkin committed Sep 25, 2023
1 parent 63ad6f6 commit 2e4bc8f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dev-helpers/oauth2-redirect.html
Expand Up @@ -6,6 +6,14 @@
<script>
'use strict';
function run () {
if (!window.opener) {
prompt("Run this in devtools on the Swagger UI page to complete auth:", [
`swaggerUIRedirectOauth2.auth.code = "${JSON.stringify((new URLSearchParams(location.search)).get('code'))}";`
`delete swaggerUIRedirectOauth2.state;`,
`swaggerUIRedirectOauth2.callback({ auth: swaggerUIRedirectOauth2.auth, redirectUrl: swaggerUIRedirectOauth2.redirectUrl});`,
].join(" "));
return;
}
var oauth2 = window.opener.swaggerUIRedirectOauth2;
var sentState = oauth2.state;
var redirectUrl = oauth2.redirectUrl;
Expand Down

0 comments on commit 2e4bc8f

Please sign in to comment.