Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix multi gdrive external storage bug #29

Merged
merged 1 commit into from
Apr 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 28 additions & 29 deletions 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
*/
$('#files_external').on('oauth_step1', '.configuration', 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.on('oauth_step1', '.configuration', 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);
});

$('#files_external').on('oauth_step2', '.configuration', function (event, data) {
if (data['backend_id'] !== backendId || data['code'] === undefined) {
return; // means the trigger is not for this OAuth2 grant
}
$tr.on('oauth_step2', '.configuration', 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_gdrive', 'Error verifying OAuth2 Code for ' + backendId)
);
});
OCA.External.Settings.OAuth2.verifyCode(backendUrl, data)
.fail(function (message) {
OC.dialogs.alert(message,
t('files_external_gdrive', 'Error verifying OAuth2 Code for ' + backendId)
);
});
});
}
});

});