@@ -18,28 +18,32 @@ class TwitterLogin extends Component {
1818 }
1919
2020 getRequestToken ( ) {
21+ var popup = this . openPopup ( ) ;
22+
2123 return window . fetch ( this . props . requestTokenUrl , {
2224 method : 'POST' ,
25+ credentials : 'same-origin' ,
2326 headers : {
2427 'Content-Type' : 'application/json'
2528 }
2629 } ) . then ( response => {
2730 return response . json ( ) ;
2831 } ) . then ( data => {
29- this . openPopup ( data . oauth_token ) ;
32+ popup . location = `https://api.twitter.com/oauth/authenticate?oauth_token=${ data . oauth_token } ` ;
33+ this . polling ( popup ) ;
3034 } ) . catch ( error => {
35+ popup . close ( ) ;
3136 return this . props . onFailure ( error ) ;
3237 } ) ;
3338 }
3439
35- openPopup ( token ) {
40+ openPopup ( ) {
3641 const w = this . props . dialogWidth ;
3742 const h = this . props . dialogHeight ;
3843 const left = ( screen . width / 2 ) - ( w / 2 ) ;
3944 const top = ( screen . height / 2 ) - ( h / 2 ) ;
40- const popup = window . open ( `https://api.twitter.com/oauth/authenticate?oauth_token=${ token } ` , '' , 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left ) ;
4145
42- this . polling ( popup ) ;
46+ return window . open ( '' , '' , 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left ) ;
4347 }
4448
4549 polling ( popup ) {
@@ -86,6 +90,7 @@ class TwitterLogin extends Component {
8690 getOathToken ( oAuthVerifier , oauthToken ) {
8791 return window . fetch ( `${ this . props . loginUrl } ?oauth_verifier=${ oAuthVerifier } &oauth_token=${ oauthToken } ` , {
8892 method : 'POST' ,
93+ credentials : 'same-origin' ,
8994 headers : {
9095 'Content-Type' : 'application/json'
9196 }
0 commit comments