Skip to content

Commit bcfe799

Browse files
committed
Improve detecting of oauthVerifier and ouathToken in popup
1 parent d51bdb6 commit bcfe799

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,32 @@ class TwitterLogin extends Component {
4949
this.props.onFailure(new Error('Popup has been closed by user'));
5050
}
5151

52+
const closeDialog = () => {
53+
clearInterval(polling);
54+
popup.close();
55+
};
56+
5257
try {
53-
if (!popup.location.hostname.includes('api.twitter.com')) {
58+
if (!popup.location.hostname.includes('api.twitter.com') &&
59+
!popup.location.hostname == '') {
5460
if (popup.location.search) {
5561
const query = new URLSearchParams(popup.location.search);
5662

5763
const oauthToken = query.get('oauth_token');
5864
const oauthVerifier = query.get('oauth_verifier');
5965

60-
this.getOathToken(oauthVerifier, oauthToken);
66+
closeDialog();
67+
return this.getOathToken(oauthVerifier, oauthToken);
6168
} else {
62-
this.props.onFailure(new Error(
69+
closeDialog();
70+
return this.props.onFailure(new Error(
6371
'OAuth redirect has occurred but no query or hash parameters were found. ' +
6472
'They were either not set during the redirect, or were removed—typically by a ' +
6573
'routing library—before Twitter react component could read it.'
6674
));
6775
}
6876

69-
clearInterval(polling);
70-
popup.close();
77+
7178
}
7279
} catch (error) {
7380
// Ignore DOMException: Blocked a frame with origin from accessing a cross-origin frame.

0 commit comments

Comments
 (0)