summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2014-05-16 12:23:01 -0400
committerBjörn Schießle <schiessle@owncloud.com>2014-05-16 12:23:01 -0400
commitb52cb8f5570f4ec0e73aa5b2e1a5dbd178135382 (patch)
tree8e622b686a60a49bbe6cf21469a232dcb72e6eea /core/js
parentd5f60a8eb0b3521ba0d85e9191468f09ea37803e (diff)
parentb6e14af861481d0b2ebf6ca752d994c5adfce866 (diff)
downloadnextcloud-server-b52cb8f5570f4ec0e73aa5b2e1a5dbd178135382.tar.gz
nextcloud-server-b52cb8f5570f4ec0e73aa5b2e1a5dbd178135382.zip
Merge pull request #8604 from owncloud/sharing_encforce_password
allow admin to enforce passwords for public link shares
Diffstat (limited to 'core/js')
-rw-r--r--core/js/config.php1
-rw-r--r--core/js/share.js52
2 files changed, 34 insertions, 19 deletions
diff --git a/core/js/config.php b/core/js/config.php
index 9169cc14a7b..33665b8401c 100644
--- a/core/js/config.php
+++ b/core/js/config.php
@@ -79,6 +79,7 @@ $array = array(
'defaultExpireDateEnabled' => $defaultExpireDateEnabled,
'defaultExpireDate' => $defaultExpireDate,
'defaultExpireDateEnforced' => $enforceDefaultExpireDate,
+ 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(),
)
)
),
diff --git a/core/js/share.js b/core/js/share.js
index 9ceca85bff7..6c6631aa2b2 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -230,11 +230,11 @@ OC.Share={
}
html += '<input id="linkText" type="text" readonly="readonly" />';
-
html += '<input type="checkbox" name="showPassword" id="showPassword" value="1" style="display:none;" /><label for="showPassword" style="display:none;">'+t('core', 'Password protect')+'</label>';
html += '<div id="linkPass">';
- html += '<input id="linkPassText" type="password" placeholder="'+t('core', 'Password')+'" />';
+ html += '<input id="linkPassText" type="password" placeholder="'+t('core', 'Choose a password for the public link')+'" />';
html += '</div>';
+
if (itemType === 'folder' && (possiblePermissions & OC.PERMISSION_CREATE) && publicUploadEnabled === 'yes') {
html += '<div id="allowPublicUploadWrapper" style="display:none;">';
html += '<input type="checkbox" value="1" name="allowPublicUpload" id="sharingDialogAllowPublicUpload"' + ((allowPublicUploadStatus) ? 'checked="checked"' : '') + ' />';
@@ -494,8 +494,10 @@ OC.Share={
$('#linkText').val(link);
$('#linkText').show('blind');
$('#linkText').css('display','block');
- $('#showPassword').show();
- $('#showPassword+label').show();
+ if (oc_appconfig.core.enforcePasswordForPublicLink === false || password === null) {
+ $('#showPassword').show();
+ $('#showPassword+label').show();
+ }
if (password != null) {
$('#linkPass').show('blind');
$('#showPassword').attr('checked', true);
@@ -512,7 +514,7 @@ OC.Share={
$('#defaultExpireMessage').hide();
$('#showPassword').hide();
$('#showPassword+label').hide();
- $('#linkPass').hide();
+ $('#linkPass').hide('blind');
$('#emailPrivateLink #email').hide();
$('#emailPrivateLink #emailButton').hide();
$('#allowPublicUploadWrapper').hide();
@@ -643,20 +645,27 @@ $(document).ready(function() {
var itemSourceName = $('#dropdown').data('item-source-name');
if (this.checked) {
// Create a link
- OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, itemSourceName, function(data) {
- OC.Share.showLink(data.token, null, itemSource);
- OC.Share.updateIcon(itemType, itemSource);
- });
+ if (oc_appconfig.core.enforcePasswordForPublicLink === false) {
+ OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, itemSourceName, function(data) {
+ OC.Share.showLink(data.token, null, itemSource);
+ OC.Share.updateIcon(itemType, itemSource);
+ });
+ } else {
+ $('#linkPass').toggle('blind');
+ $('#linkPassText').focus();
+ }
} else {
// Delete private link
- OC.Share.unshare(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', function() {
- OC.Share.hideLink();
- OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = false;
- OC.Share.updateIcon(itemType, itemSource);
- if (typeof OC.Share.statuses[itemSource] === 'undefined') {
- $('#expiration').hide('blind');
- }
- });
+ OC.Share.hideLink();
+ if ($('#linkText').val() !== '') {
+ OC.Share.unshare(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', function() {
+ OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = false;
+ OC.Share.updateIcon(itemType, itemSource);
+ if (typeof OC.Share.statuses[itemSource] === 'undefined') {
+ $('#expiration').hide('blind');
+ }
+ });
+ }
}
});
@@ -728,11 +737,16 @@ $(document).ready(function() {
permissions = OC.PERMISSION_READ;
}
- OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $('#linkPassText').val(), permissions, itemSourceName, function() {
- console.log("password set to: '" + linkPassText.val() +"' by event: " + event.type);
+ OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $('#linkPassText').val(), permissions, itemSourceName, function(data) {
linkPassText.val('');
linkPassText.attr('placeholder', t('core', 'Password protected'));
+
+ if (oc_appconfig.core.enforcePasswordForPublicLink) {
+ OC.Share.showLink(data.token, "password set", itemSource);
+ OC.Share.updateIcon(itemType, itemSource);
+ }
});
+
}
});