Fix Google Data isAuthorized check - fixes #3054 (#3612)

- adjust for new undefined return value of new cookies package
- add some error handling in case we think we're logged in, but really aren't
This commit is contained in:
Tom Morris 2021-02-11 13:50:10 -05:00 committed by GitHub
parent ff0b81e0f0
commit 8b459d69e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 17 deletions

View File

@ -35,7 +35,7 @@ var GdataExtension = {};
GdataExtension.isAuthorized = function() {
// TODO: Unreliable - just means that we were authorized at one point
return Cookies.get('oauth2_token') !== null;
return Cookies.get('oauth2_token') != null;
};
GdataExtension.showAuthorizationDialog = function(onAuthorized, onNotAuthorized) {

View File

@ -128,10 +128,6 @@ Refine.GDataSourceUI.prototype._listDocuments = function() {
Refine.GDataSourceUI.prototype._renderDocuments = function(o) {
var self = this;
if (!o.documents) {
return;
}
this._elmts.listingContainer.empty();
var table = $(
@ -186,6 +182,11 @@ Refine.GDataSourceUI.prototype._renderDocuments = function(o) {
.appendTo(td);
};
if (o.status === 'error') {
// We're probably not logged in, even though we thought we were. Show signin page
this._body.find('.gdata-page').hide();
this._elmts.signinPage.show();
} else {
var docs = o.documents;
$.each(docs, function() {
this.updatedDate = (this.updated) ? new Date(this.updated) : null;
@ -199,4 +200,5 @@ Refine.GDataSourceUI.prototype._renderDocuments = function(o) {
this._body.find('.gdata-page').hide();
this._elmts.listingPage.show();
}
};