mirror of https://github.com/keeweb/keeweb.git
fix #176: logout from remote storages on disable
This commit is contained in:
parent
571702a8f8
commit
6ba0808c17
|
@ -263,6 +263,17 @@ var DropboxLink = {
|
|||
this._getClient(function(err) { complete(err); }, overrideAppKey);
|
||||
},
|
||||
|
||||
logout: function() {
|
||||
if (this._dropboxClient) {
|
||||
try {
|
||||
this._dropboxClient.signOut();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
this._dropboxClient.reset();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
resetClient: function() {
|
||||
this._dropboxClient = null;
|
||||
},
|
||||
|
|
|
@ -37,6 +37,10 @@ _.extend(StorageBase.prototype, {
|
|||
return this;
|
||||
},
|
||||
|
||||
setEnabled: function(enabled) {
|
||||
this.enabled = enabled;
|
||||
},
|
||||
|
||||
_xhr: function(config) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
if (config.responseType) {
|
||||
|
@ -186,6 +190,18 @@ _.extend(StorageBase.prototype, {
|
|||
this._oauthToken.expired = true;
|
||||
this.runtimeData.set(this.name + 'OAuthToken', this._oauthToken);
|
||||
this._oauthAuthorize(callback);
|
||||
},
|
||||
|
||||
_oauthRevokeToken: function(url) {
|
||||
var token = this.runtimeData.get(this.name + 'OAuthToken');
|
||||
if (token) {
|
||||
this._xhr({
|
||||
url: url.replace('{token}', token.accessToken),
|
||||
statuses: [200, 401]
|
||||
});
|
||||
this.runtimeData.unset(this.name + 'OAuthToken');
|
||||
this._oauthToken = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -223,6 +223,13 @@ var StorageDropbox = StorageBase.extend({
|
|||
that.logger.debug('Removed', path, that.logger.ts(ts));
|
||||
return callback && callback(err);
|
||||
}, _.noop);
|
||||
},
|
||||
|
||||
setEnabled: function(enabled) {
|
||||
if (!enabled) {
|
||||
DropboxLink.logout();
|
||||
}
|
||||
StorageBase.prototype.setEnabled.call(this, enabled);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -180,6 +180,13 @@ var StorageGDrive = StorageBase.extend({
|
|||
});
|
||||
},
|
||||
|
||||
setEnabled: function(enabled) {
|
||||
if (!enabled) {
|
||||
this._oauthRevokeToken('https://accounts.google.com/o/oauth2/revoke?token={token}');
|
||||
}
|
||||
StorageBase.prototype.setEnabled.call(this, enabled);
|
||||
},
|
||||
|
||||
_getOAuthConfig: function() {
|
||||
var clientId = this.appSettings.get('gdriveClientId') || GDriveClientId;
|
||||
return {
|
||||
|
|
|
@ -197,6 +197,16 @@ var StorageOneDrive = StorageBase.extend({
|
|||
});
|
||||
},
|
||||
|
||||
setEnabled: function(enabled) {
|
||||
if (!enabled) {
|
||||
var url = 'https://login.live.com/oauth20_logout.srf?client_id={client_id}&redirect_uri={url}'
|
||||
.replace('{client_id}', this._getClientId())
|
||||
.replace('{url}', this._getOauthRedirectUrl());
|
||||
this._oauthRevokeToken(url);
|
||||
}
|
||||
StorageBase.prototype.setEnabled.call(this, enabled);
|
||||
},
|
||||
|
||||
_getClientId: function() {
|
||||
var clientId = this.appSettings.get('onedriveClientId');
|
||||
if (!clientId) {
|
||||
|
|
|
@ -264,7 +264,7 @@ var SettingsGeneralView = Backbone.View.extend({
|
|||
changeStorageEnabled: function(e) {
|
||||
var storage = Storage[$(e.target).data('storage')];
|
||||
if (storage) {
|
||||
storage.enabled = e.target.checked;
|
||||
storage.setEnabled(e.target.checked);
|
||||
AppSettingsModel.instance.set(storage.name, storage.enabled);
|
||||
this.$el.find('.settings__general-' + storage.name).toggleClass('hide', !e.target.checked);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ Auto-type, ui improvements
|
|||
`+` improved start page ux on mobile
|
||||
`+` option to show app logs
|
||||
`+` group info in entry details
|
||||
`+` logout from remote storages on disable
|
||||
`*` don't check updates at startup
|
||||
`-` prevent second app instance on windows
|
||||
`-` fix drag-drop in Safari
|
||||
|
|
Loading…
Reference in New Issue