Skip to content

Commit

Permalink
Upgrade version flutter_web_auth_2 and fix can't close SSO
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev authored and hoangdat committed Jan 5, 2024
1 parent 6834292 commit 29c86bb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies:
flutter_secure_storage: ^7.0.1
flutter_svg: ^0.22.0
flutter_typeahead: ^5.0.0
flutter_web_auth_2: ^3.0.2
flutter_web_auth_2: ^3.1.1
# flutter_webrtc: # Until https://github.com/flutter-webrtc/flutter-webrtc/issues/1212 is fixed
# git: https://github.com/radzio-it/flutter-webrtc.git
flutter_webrtc: ^0.9.31
Expand Down
32 changes: 20 additions & 12 deletions web/auth.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
<!DOCTYPE html>
<head>
<title>Authentication complete</title>
</head>
<body>
<p>Authentication is complete. If this does not happen automatically, please
close the window.
<script>
window.opener.postMessage({
<title>Authentication complete</title>
<p>Authentication is complete. If this does not happen automatically, please close the window.</p>
<script>
function postAuthenticationMessage() {
const message = {
'flutter-web-auth-2': window.location.href
}, window.location.origin);
window.close();
</script>
</body>
};

if (window.opener) {
window.opener.postMessage(message, window.location.origin);
window.close();
} else if (window.parent && window.parent !== window) {
window.parent.postMessage(message, window.location.origin);
} else {
localStorage.setItem('flutter-web-auth-2', window.location.href);
window.close();
}
}

postAuthenticationMessage();
</script>

0 comments on commit 29c86bb

Please sign in to comment.