Fix OAuth external storage auth for step 2

Parameters are only available after the onCompletion promise is run
This commit is contained in:
Robin McCorkell 2016-01-07 16:44:17 +00:00
parent e307406486
commit 430c5df6c4
2 changed files with 82 additions and 78 deletions

View File

@ -1,6 +1,6 @@
$(document).ready(function() { $(document).ready(function() {
OCA.External.Settings.mountConfig.whenSelectAuthMechanism(function($tr, authMechanism, scheme) { OCA.External.Settings.mountConfig.whenSelectAuthMechanism(function($tr, authMechanism, scheme, onCompletion) {
if (authMechanism === 'oauth1::oauth1') { if (authMechanism === 'oauth1::oauth1') {
var config = $tr.find('.configuration'); var config = $tr.find('.configuration');
config.append($(document.createElement('input')) config.append($(document.createElement('input'))
@ -10,6 +10,7 @@ $(document).ready(function() {
.attr('name', 'oauth1_grant') .attr('name', 'oauth1_grant')
); );
onCompletion.then(function() {
var configured = $tr.find('[data-parameter="configured"]'); var configured = $tr.find('[data-parameter="configured"]');
if ($(configured).val() == 'true') { if ($(configured).val() == 'true') {
$tr.find('.configuration input').attr('disabled', 'disabled'); $tr.find('.configuration input').attr('disabled', 'disabled');
@ -43,6 +44,7 @@ $(document).ready(function() {
} }
} }
} }
});
} }
}); });

View File

@ -1,6 +1,6 @@
$(document).ready(function() { $(document).ready(function() {
OCA.External.Settings.mountConfig.whenSelectAuthMechanism(function($tr, authMechanism, scheme) { OCA.External.Settings.mountConfig.whenSelectAuthMechanism(function($tr, authMechanism, scheme, onCompletion) {
if (authMechanism === 'oauth2::oauth2') { if (authMechanism === 'oauth2::oauth2') {
var config = $tr.find('.configuration'); var config = $tr.find('.configuration');
config.append($(document.createElement('input')) config.append($(document.createElement('input'))
@ -10,6 +10,7 @@ $(document).ready(function() {
.attr('name', 'oauth2_grant') .attr('name', 'oauth2_grant')
); );
onCompletion.then(function() {
var configured = $tr.find('[data-parameter="configured"]'); var configured = $tr.find('[data-parameter="configured"]');
if ($(configured).val() == 'true') { if ($(configured).val() == 'true') {
$tr.find('.configuration input').attr('disabled', 'disabled'); $tr.find('.configuration input').attr('disabled', 'disabled');
@ -58,6 +59,7 @@ $(document).ready(function() {
} }
} }
} }
});
} }
}); });