File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -35,11 +35,18 @@ var Login = React.createClass({
3535 var authUrl = githubUrl + 'client_id=' + options . client_id + '&scope=' + options . scope ;
3636 authWindow . loadUrl ( authUrl ) ;
3737
38+ authWindow . webContents . on ( 'will-navigate' , function ( event , url ) {
39+ handleCallback ( url ) ;
40+ } ) ;
41+
3842 authWindow . webContents . on ( 'did-get-redirect-request' , function ( event , oldUrl , newUrl ) {
43+ handleCallback ( newUrl ) ;
44+ } ) ;
3945
40- var raw_code = / c o d e = ( [ ^ & ] * ) / . exec ( newUrl ) || null ;
46+ function handleCallback ( url ) {
47+ var raw_code = / c o d e = ( [ ^ & ] * ) / . exec ( url ) || null ;
4148 var code = ( raw_code && raw_code . length > 1 ) ? raw_code [ 1 ] : null ;
42- var error = / \? e r r o r = ( .+ ) $ / . exec ( newUrl ) ;
49+ var error = / \? e r r o r = ( .+ ) $ / . exec ( url ) ;
4350
4451 if ( code || error ) {
4552 // Close the browser if code found or error
@@ -53,8 +60,7 @@ var Login = React.createClass({
5360 alert ( 'Oops! Something went wrong and we couldn\'t' +
5461 'log you in using Github. Please try again.' ) ;
5562 }
56-
57- } ) ;
63+ }
5864
5965 // If "Done" button is pressed, hide "Loading"
6066 authWindow . on ( 'close' , function ( ) {
You can’t perform that action at this time.
0 commit comments