Skip to content

Commit

Permalink
fix multi gdrive external storage bug
Browse files Browse the repository at this point in the history
  • Loading branch information
karakayasemi committed Apr 8, 2019
1 parent 294ecdb commit 1b05dce
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
57 changes: 28 additions & 29 deletions apps/files_external/js/gdrive.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,37 @@ $(document).ready(function() {
});
el.tooltip({placement: 'top'});
backendEl.append(el);
}
});

/**
* ------- OAUTH2 Events ----------
*
* The files_external_{backendId} app's CUSTOM JS should handle the OAuth2 events itself
* instead on relying on the core for the implemention. These two functions
* [1] OCA.External.Settings.OAuth2.getAuthUrl, [2] OCA.External.Settings.OAuth2.verifyCode
* abstract away the details of sending the request to backend for getting the AuthURL or
* verifying the code, mounting the storage config etc
*/
$('.configuration').on('oauth_step1', function (event, data) {
if (data['backend_id'] !== backendId) {
return; // means the trigger is not for this storage adapter
}
/**
* ------- OAUTH2 Events ----------
*
* The files_external_{backendId} app's CUSTOM JS should handle the OAuth2 events itself
* instead on relying on the core for the implemention. These two functions
* [1] OCA.External.Settings.OAuth2.getAuthUrl, [2] OCA.External.Settings.OAuth2.verifyCode
* abstract away the details of sending the request to backend for getting the AuthURL or
* verifying the code, mounting the storage config etc
*/
$tr.find('.configuration').on('oauth_step1', function (event, data) {
if (data['backend_id'] !== backendId) {
return; // means the trigger is not for this storage adapter
}

// Redirects the User on success else displays an alert (with error message sent by backend)
OCA.External.Settings.OAuth2.getAuthUrl(backendUrl, data);
});
// Redirects the User on success else displays an alert (with error message sent by backend)
OCA.External.Settings.OAuth2.getAuthUrl(backendUrl, data);
});

$('.configuration').on('oauth_step2', function (event, data) {
if (data['backend_id'] !== backendId || data['code'] === undefined) {
return; // means the trigger is not for this OAuth2 grant
}
$tr.find('.configuration').on('oauth_step2', function (event, data) {
if (data['backend_id'] !== backendId || data['code'] === undefined) {
return; // means the trigger is not for this OAuth2 grant
}

OCA.External.Settings.OAuth2.verifyCode(backendUrl, data)
.fail(function (message) {
OC.dialogs.alert(message,
t('files_external', 'Error verifying OAuth2 Code for ' + backendId)
);
})
OCA.External.Settings.OAuth2.verifyCode(backendUrl, data)
.fail(function (message) {
OC.dialogs.alert(message,
t('files_external', 'Error verifying OAuth2 Code for ' + backendId)
);
});
});
}
});

});
5 changes: 4 additions & 1 deletion apps/files_external/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,10 @@ MountConfigListView.prototype = _.extend({
classOptions[parameter] = false;
}
} else {
classOptions[parameter] = $(input).val();
classOptions[parameter] = 'false';
if($(input).val()) {
classOptions[parameter] = $(input).val();
}
}
});

Expand Down

0 comments on commit 1b05dce

Please sign in to comment.