diff options
-rw-r--r-- | apps/files_external/js/oauth1.js | 66 | ||||
-rw-r--r-- | apps/files_external/js/oauth2.js | 94 | ||||
-rw-r--r-- | settings/templates/personal.php | 28 |
3 files changed, 87 insertions, 101 deletions
diff --git a/apps/files_external/js/oauth1.js b/apps/files_external/js/oauth1.js index 47aca36871f..e2ba25ebf8e 100644 --- a/apps/files_external/js/oauth1.js +++ b/apps/files_external/js/oauth1.js @@ -1,6 +1,6 @@ $(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') { var config = $tr.find('.configuration'); config.append($(document.createElement('input')) @@ -10,39 +10,41 @@ $(document).ready(function() { .attr('name', 'oauth1_grant') ); - var configured = $tr.find('[data-parameter="configured"]'); - if ($(configured).val() == 'true') { - $tr.find('.configuration input').attr('disabled', 'disabled'); - $tr.find('.configuration').append('<span id="access" style="padding-left:0.5em;">'+t('files_external', 'Access granted')+'</span>'); - } else { - var app_key = $tr.find('.configuration [data-parameter="app_key"]').val(); - var app_secret = $tr.find('.configuration [data-parameter="app_secret"]').val(); - if (app_key != '' && app_secret != '') { - var pos = window.location.search.indexOf('oauth_token') + 12; - var token = $tr.find('.configuration [data-parameter="token"]'); - if (pos != -1 && window.location.search.substr(pos, $(token).val().length) == $(token).val()) { - var token_secret = $tr.find('.configuration [data-parameter="token_secret"]'); - var statusSpan = $tr.find('.status span'); - statusSpan.removeClass(); - statusSpan.addClass('waiting'); - $.post(OC.filePath('files_external', 'ajax', 'oauth1.php'), { step: 2, app_key: app_key, app_secret: app_secret, request_token: $(token).val(), request_token_secret: $(token_secret).val() }, function(result) { - if (result && result.status == 'success') { - $(token).val(result.access_token); - $(token_secret).val(result.access_token_secret); - $(configured).val('true'); - OCA.External.Settings.mountConfig.saveStorageConfig($tr, function(status) { - if (status) { - $tr.find('.configuration input').attr('disabled', 'disabled'); - $tr.find('.configuration').append('<span id="access" style="padding-left:0.5em;">'+t('files_external', 'Access granted')+'</span>'); - } - }); - } else { - OC.dialogs.alert(result.data.message, t('files_external', 'Error configuring OAuth1')); - } - }); + onCompletion.then(function() { + var configured = $tr.find('[data-parameter="configured"]'); + if ($(configured).val() == 'true') { + $tr.find('.configuration input').attr('disabled', 'disabled'); + $tr.find('.configuration').append('<span id="access" style="padding-left:0.5em;">'+t('files_external', 'Access granted')+'</span>'); + } else { + var app_key = $tr.find('.configuration [data-parameter="app_key"]').val(); + var app_secret = $tr.find('.configuration [data-parameter="app_secret"]').val(); + if (app_key != '' && app_secret != '') { + var pos = window.location.search.indexOf('oauth_token') + 12; + var token = $tr.find('.configuration [data-parameter="token"]'); + if (pos != -1 && window.location.search.substr(pos, $(token).val().length) == $(token).val()) { + var token_secret = $tr.find('.configuration [data-parameter="token_secret"]'); + var statusSpan = $tr.find('.status span'); + statusSpan.removeClass(); + statusSpan.addClass('waiting'); + $.post(OC.filePath('files_external', 'ajax', 'oauth1.php'), { step: 2, app_key: app_key, app_secret: app_secret, request_token: $(token).val(), request_token_secret: $(token_secret).val() }, function(result) { + if (result && result.status == 'success') { + $(token).val(result.access_token); + $(token_secret).val(result.access_token_secret); + $(configured).val('true'); + OCA.External.Settings.mountConfig.saveStorageConfig($tr, function(status) { + if (status) { + $tr.find('.configuration input').attr('disabled', 'disabled'); + $tr.find('.configuration').append('<span id="access" style="padding-left:0.5em;">'+t('files_external', 'Access granted')+'</span>'); + } + }); + } else { + OC.dialogs.alert(result.data.message, t('files_external', 'Error configuring OAuth1')); + } + }); + } } } - } + }); } }); diff --git a/apps/files_external/js/oauth2.js b/apps/files_external/js/oauth2.js index 84941437420..2556bf45cae 100644 --- a/apps/files_external/js/oauth2.js +++ b/apps/files_external/js/oauth2.js @@ -1,6 +1,6 @@ $(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') { var config = $tr.find('.configuration'); config.append($(document.createElement('input')) @@ -10,54 +10,56 @@ $(document).ready(function() { .attr('name', 'oauth2_grant') ); - var configured = $tr.find('[data-parameter="configured"]'); - if ($(configured).val() == 'true') { - $tr.find('.configuration input').attr('disabled', 'disabled'); - $tr.find('.configuration').append($('<span/>').attr('id', 'access') - .text(t('files_external', 'Access granted'))); - } else { - var client_id = $tr.find('.configuration [data-parameter="client_id"]').val(); - var client_secret = $tr.find('.configuration [data-parameter="client_secret"]') - .val(); - if (client_id != '' && client_secret != '') { - var params = {}; - window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) { - params[key] = value; - }); - if (params['code'] !== undefined) { - var token = $tr.find('.configuration [data-parameter="token"]'); - var statusSpan = $tr.find('.status span'); - statusSpan.removeClass(); - statusSpan.addClass('waiting'); - $.post(OC.filePath('files_external', 'ajax', 'oauth2.php'), - { - step: 2, - client_id: client_id, - client_secret: client_secret, - redirect: location.protocol + '//' + location.host + location.pathname, - code: params['code'], - }, function(result) { - if (result && result.status == 'success') { - $(token).val(result.data.token); - $(configured).val('true'); - OCA.External.Settings.mountConfig.saveStorageConfig($tr, function(status) { - if (status) { - $tr.find('.configuration input').attr('disabled', 'disabled'); - $tr.find('.configuration').append($('<span/>') - .attr('id', 'access') - .text(t('files_external', 'Access granted'))); - } - }); - } else { - OC.dialogs.alert(result.data.message, - t('files_external', 'Error configuring OAuth2') - ); + onCompletion.then(function() { + var configured = $tr.find('[data-parameter="configured"]'); + if ($(configured).val() == 'true') { + $tr.find('.configuration input').attr('disabled', 'disabled'); + $tr.find('.configuration').append($('<span/>').attr('id', 'access') + .text(t('files_external', 'Access granted'))); + } else { + var client_id = $tr.find('.configuration [data-parameter="client_id"]').val(); + var client_secret = $tr.find('.configuration [data-parameter="client_secret"]') + .val(); + if (client_id != '' && client_secret != '') { + var params = {}; + window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) { + params[key] = value; + }); + if (params['code'] !== undefined) { + var token = $tr.find('.configuration [data-parameter="token"]'); + var statusSpan = $tr.find('.status span'); + statusSpan.removeClass(); + statusSpan.addClass('waiting'); + $.post(OC.filePath('files_external', 'ajax', 'oauth2.php'), + { + step: 2, + client_id: client_id, + client_secret: client_secret, + redirect: location.protocol + '//' + location.host + location.pathname, + code: params['code'], + }, function(result) { + if (result && result.status == 'success') { + $(token).val(result.data.token); + $(configured).val('true'); + OCA.External.Settings.mountConfig.saveStorageConfig($tr, function(status) { + if (status) { + $tr.find('.configuration input').attr('disabled', 'disabled'); + $tr.find('.configuration').append($('<span/>') + .attr('id', 'access') + .text(t('files_external', 'Access granted'))); + } + }); + } else { + OC.dialogs.alert(result.data.message, + t('files_external', 'Error configuring OAuth2') + ); + } } - } - ); + ); + } } } - } + }); } }); diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 86843df9922..ce179ca8788 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -4,8 +4,8 @@ * See the COPYING-README file. */ -/** @var $_ array */ -/** @var $_['urlGenerator'] */ +/** @var $_ mixed[]|\OCP\IURLGenerator[] */ +/** @var \OC_Defaults $theme */ ?> <div id="app-navigation"> @@ -22,8 +22,6 @@ <div id="app-content"> - - <div id="quota" class="section"> <div style="width:<?php p($_['usage_relative']);?>%" <?php if($_['usage_relative'] > 80): ?> class="quota-warning" <?php endif; ?>> @@ -34,8 +32,6 @@ </div> </div> - - <?php if ($_['enableAvatars']): ?> <form id="avatar" class="section" method="post" action="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.postAvatar')); ?>"> <h2><?php p($l->t('Profile picture')); ?></h2> @@ -60,8 +56,6 @@ </form> <?php endif; ?> - - <?php if($_['displayNameChangeSupported']) { ?> @@ -86,8 +80,6 @@ if($_['displayNameChangeSupported']) { } ?> - - <?php if($_['passwordChangeSupported']) { ?> @@ -112,8 +104,6 @@ if($_['passwordChangeSupported']) { } ?> - - <div id="groups" class="section"> <h2><?php p($l->t('Groups')); ?></h2> <p><?php p($l->t('You are member of the following groups:')); ?></p> @@ -122,8 +112,6 @@ if($_['passwordChangeSupported']) { </p> </div> - - <?php if($_['passwordChangeSupported']) { script('jquery-showpassword'); @@ -151,8 +139,6 @@ if($_['passwordChangeSupported']) { } ?> - - <form class="section"> <h2> <label for="languageinput"><?php p($l->t('Language'));?></label> @@ -181,8 +167,6 @@ if($_['passwordChangeSupported']) { <?php endif; ?> </form> - - <div id="clientsbox" class="section clientsbox"> <h2><?php p($l->t('Get the apps to sync your files'));?></h2> <a href="<?php p($_['clients']['desktop']); ?>" target="_blank"> @@ -214,8 +198,6 @@ if($_['passwordChangeSupported']) { <?php }?> </div> - - <?php foreach($_['forms'] as $form) { if (isset($form['form'])) {?> <div id="<?php isset($form['anchor']) ? p($form['anchor']) : p('');?>"><?php print_unescaped($form['form']);?></div> @@ -227,10 +209,12 @@ if($_['passwordChangeSupported']) { <h2><?php p($l->t('SSL root certificates')); ?></h2> <table id="sslCertificate" class="grid"> <thead> + <tr> <th><?php p($l->t('Common Name')); ?></th> <th><?php p($l->t('Valid until')); ?></th> <th><?php p($l->t('Issued By')); ?></th> - <th/> + <th></th> + </tr> </thead> <tbody> <?php foreach ($_['certs'] as $rootCert): /**@var \OCP\ICertificate $rootCert*/ ?> @@ -268,6 +252,4 @@ if($_['passwordChangeSupported']) { <p><?php include('settings.development.notice.php'); ?></p> </div> - - </div> |