Skip to content

Commit

Permalink
Correctly recognize cancellation of Dropbox login
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancarter committed Sep 7, 2017
1 parent 7cbaa6a commit b02cc13
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ two functions, about half way through [cloud-storage.js](cloud-storage.js).

## Status

There are several things that need to be improved about this project.
There are a few things that need to be improved about this project.
See [the to-do list](TODO.md) for details.

## License
Expand Down
6 changes: 0 additions & 6 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,3 @@ I list them in this file.
* In that same HTML file you will find the IDs for the files list and
buttons footer.
* Other tidbits appear in the existing [dialog.css](dialog.css) file.

## Missing pieces

* The [Dropbox back end](dropbox-backend.js) does not call the failure
callback if the user cancels the login. I don't yet know how to do this.
Figure out how and call the failure callback in such cases.
12 changes: 8 additions & 4 deletions dropbox-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ DropboxFileSystem.prototype.getAccess = function ( successCB, failureCB )
if ( command == 'dialogLogin' ) {
loginWindow.close();
that.accountData = message.shift();
that.dropbox = new Dropbox( {
accessToken : that.accountData.access_token
} );
successCB();
if ( that.accountData.access_token ) {
that.dropbox = new Dropbox( {
accessToken : that.accountData.access_token
} );
successCB();
} else {
failureCB( that.accountData );
}
}
} catch ( e ) { }
} );
Expand Down
2 changes: 1 addition & 1 deletion dropbox-login.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
* use that information to access the user's Dropbox.
*/
var hashData = parseQueryString( window.location.hash );
if ( hashData.access_token )
if ( hashData.access_token || hashData.error )
window.opener.postMessage(
JSON.stringify( [ 'dialogLogin', hashData ] ), '*' );
</script>
Expand Down

0 comments on commit b02cc13

Please sign in to comment.