Merge pull request #10695 from nextcloud/sharing-public-settings-fixes
Fix password enforce on public links
This commit is contained in:
commit
a4e042c706
|
@ -180,8 +180,8 @@
|
||||||
display: block;
|
display: block;
|
||||||
.icon-more {
|
.icon-more {
|
||||||
padding: 14px;
|
padding: 14px;
|
||||||
height: 16px;
|
height: 44px;
|
||||||
width: 16px;
|
width: 44px;
|
||||||
opacity: .5;
|
opacity: .5;
|
||||||
display: block;
|
display: block;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
|
@ -30,9 +30,13 @@
|
||||||
' <input id="linkCheckbox-{{cid}}" {{#if isLinkShare}}checked="checked"{{/if}} type="checkbox" name="linkCheckbox" class="linkCheckbox permissions checkbox">' +
|
' <input id="linkCheckbox-{{cid}}" {{#if isLinkShare}}checked="checked"{{/if}} type="checkbox" name="linkCheckbox" class="linkCheckbox permissions checkbox">' +
|
||||||
' <label for="linkCheckbox-{{cid}}">{{linkShareEnableLabel}}</label>' +
|
' <label for="linkCheckbox-{{cid}}">{{linkShareEnableLabel}}</label>' +
|
||||||
' </span>' +
|
' </span>' +
|
||||||
' {{#if isLinkShare}}' +
|
' {{#if showMenu}}' +
|
||||||
' <div class="share-menu" tabindex="0"><span class="icon icon-more"></span>' +
|
' <div class="share-menu" tabindex="0"><span class="icon icon-more"></span>' +
|
||||||
|
' {{#if showPending}}' +
|
||||||
|
' {{{pendingPopoverMenu}}}' +
|
||||||
|
' {{else}}' +
|
||||||
' {{{popoverMenu}}}' +
|
' {{{popoverMenu}}}' +
|
||||||
|
' {{/if}}' +
|
||||||
' </div>' +
|
' </div>' +
|
||||||
' {{/if}}' +
|
' {{/if}}' +
|
||||||
' </span>' +
|
' </span>' +
|
||||||
|
@ -83,7 +87,8 @@
|
||||||
'{{/if}}' +
|
'{{/if}}' +
|
||||||
'{{#if showPasswordCheckBox}}' +
|
'{{#if showPasswordCheckBox}}' +
|
||||||
' <li><span class="shareOption menuitem">' +
|
' <li><span class="shareOption menuitem">' +
|
||||||
' <input type="checkbox" name="showPassword" id="showPassword-{{cid}}" class="checkbox showPasswordCheckbox" {{#if isPasswordSet}}checked="checked"{{/if}} value="1" />' +
|
' <input type="checkbox" name="showPassword" id="showPassword-{{cid}}" class="checkbox showPasswordCheckbox"' +
|
||||||
|
' {{#if isPasswordSet}}checked="checked"{{/if}} {{#if isPasswordEnforced}}disabled="disabled"{{/if}} value="1" />' +
|
||||||
' <label for="showPassword-{{cid}}">{{enablePasswordLabel}}</label>' +
|
' <label for="showPassword-{{cid}}">{{enablePasswordLabel}}</label>' +
|
||||||
' </span></li>' +
|
' </span></li>' +
|
||||||
' <li class="{{#unless isPasswordSet}}hidden{{/unless}} linkPassMenu"><span class="shareOption menuitem icon-share-pass">' +
|
' <li class="{{#unless isPasswordSet}}hidden{{/unless}} linkPassMenu"><span class="shareOption menuitem icon-share-pass">' +
|
||||||
|
@ -92,16 +97,17 @@
|
||||||
' </span></li>' +
|
' </span></li>' +
|
||||||
'{{/if}}' +
|
'{{/if}}' +
|
||||||
'<li>' +
|
'<li>' +
|
||||||
'<span class="shareOption menuitem">' +
|
' <span class="shareOption menuitem">' +
|
||||||
'<input id="expireDate-{{cid}}" type="checkbox" name="expirationDate" class="expireDate checkbox" {{#if hasExpireDate}}checked="checked"{{/if}}" />' +
|
' <input id="expireDate-{{cid}}" type="checkbox" name="expirationDate" class="expireDate checkbox"' +
|
||||||
'<label for="expireDate-{{cid}}">{{expireDateLabel}}</label>' +
|
' {{#if hasExpireDate}}checked="checked"{{/if}} {{#if isExpirationEnforced}}disabled="disabled"{{/if}}" />' +
|
||||||
|
' <label for="expireDate-{{cid}}">{{expireDateLabel}}</label>' +
|
||||||
|
' </span>' +
|
||||||
'</li>' +
|
'</li>' +
|
||||||
'<li class="{{#unless hasExpireDate}}hidden{{/unless}}">' +
|
'<li class="{{#unless hasExpireDate}}hidden{{/unless}}">' +
|
||||||
'<span class="menuitem icon-expiredate expirationDateContainer-{{cid}}">' +
|
' <span class="menuitem icon-expiredate expirationDateContainer-{{cid}}">' +
|
||||||
' <label for="expirationDatePicker-{{cid}}" class="hidden-visually" value="{{expirationDate}}">{{expirationLabel}}</label>' +
|
' <label for="expirationDatePicker-{{cid}}" class="hidden-visually" value="{{expirationDate}}">{{expirationLabel}}</label>' +
|
||||||
' <input id="expirationDatePicker-{{cid}}" class="datepicker" type="text" placeholder="{{expirationDatePlaceholder}}" value="{{#if hasExpireDate}}{{expireDate}}{{else}}{{defaultExpireDate}}{{/if}}" />' +
|
' <input id="expirationDatePicker-{{cid}}" class="datepicker" type="text" placeholder="{{expirationDatePlaceholder}}" value="{{#if hasExpireDate}}{{expireDate}}{{else}}{{defaultExpireDate}}{{/if}}" />' +
|
||||||
'</span>' +
|
' </span>' +
|
||||||
'</span>' +
|
|
||||||
'</li>' +
|
'</li>' +
|
||||||
'<li>' +
|
'<li>' +
|
||||||
'<a href="#" class="share-add"><span class="icon-loading-small hidden"></span>' +
|
'<a href="#" class="share-add"><span class="icon-loading-small hidden"></span>' +
|
||||||
|
@ -128,6 +134,23 @@
|
||||||
'</ul>' +
|
'</ul>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
|
// popovermenu waiting for password or expiration date before saving the share
|
||||||
|
var TEMPLATE_POPOVER_MENU_PENDING =
|
||||||
|
'<div class="popovermenu pendingpopover menu">' +
|
||||||
|
'<ul>' +
|
||||||
|
'{{#if isPasswordEnforced}}' +
|
||||||
|
' <li><span class="shareOption menuitem">' +
|
||||||
|
' <input type="checkbox" name="showPassword" id="showPassword-{{cid}}" checked="checked" disabled class="checkbox showPasswordCheckbox" value="1" />' +
|
||||||
|
' <label for="showPassword-{{cid}}">{{enablePasswordLabel}}</label>' +
|
||||||
|
' </span></li>' +
|
||||||
|
' <li class="linkPassMenu"><span class="shareOption menuitem icon-share-pass">' +
|
||||||
|
' <input id="linkPassText-{{cid}}" class="linkPassText" type="password" placeholder="{{passwordPlaceholder}}" autocomplete="new-password" />' +
|
||||||
|
' <span class="icon icon-loading-small hidden"></span>' +
|
||||||
|
' </span></li>' +
|
||||||
|
'{{/if}}' +
|
||||||
|
'</ul>' +
|
||||||
|
'</div>';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class OCA.Share.ShareDialogLinkShareView
|
* @class OCA.Share.ShareDialogLinkShareView
|
||||||
* @member {OC.Share.ShareItemModel} model
|
* @member {OC.Share.ShareItemModel} model
|
||||||
|
@ -151,22 +174,36 @@
|
||||||
/** @type {Function} **/
|
/** @type {Function} **/
|
||||||
_popoverMenuTemplate: undefined,
|
_popoverMenuTemplate: undefined,
|
||||||
|
|
||||||
|
/** @type {Function} **/
|
||||||
|
_pendingPopoverMenuTemplate: undefined,
|
||||||
|
|
||||||
/** @type {boolean} **/
|
/** @type {boolean} **/
|
||||||
showLink: true,
|
showLink: true,
|
||||||
|
|
||||||
|
/** @type {boolean} **/
|
||||||
|
showPending: false,
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
|
// enable/disable
|
||||||
|
'change .linkCheckbox': 'onLinkCheckBoxChange',
|
||||||
|
// open menu
|
||||||
|
'click .share-menu .icon-more': 'onToggleMenu',
|
||||||
|
// password
|
||||||
'focusout input.linkPassText': 'onPasswordEntered',
|
'focusout input.linkPassText': 'onPasswordEntered',
|
||||||
'keyup input.linkPassText': 'onPasswordKeyUp',
|
'keyup input.linkPassText': 'onPasswordKeyUp',
|
||||||
'click .linkCheckbox': 'onLinkCheckBoxChange',
|
'change .showPasswordCheckbox': 'onShowPasswordClick',
|
||||||
'click .linkText': 'onLinkTextClick',
|
|
||||||
'change .publicEditingCheckbox': 'onAllowPublicEditingChange',
|
'change .publicEditingCheckbox': 'onAllowPublicEditingChange',
|
||||||
'click .showPasswordCheckbox': 'onShowPasswordClick',
|
// copy link url
|
||||||
'click .share-menu .icon-more': 'onToggleMenu',
|
'click .linkText': 'onLinkTextClick',
|
||||||
|
// social
|
||||||
'click .pop-up': 'onPopUpClick',
|
'click .pop-up': 'onPopUpClick',
|
||||||
|
// permission change
|
||||||
'change .publicUploadRadio': 'onPublicUploadChange',
|
'change .publicUploadRadio': 'onPublicUploadChange',
|
||||||
|
// expire date
|
||||||
'click .expireDate' : 'onExpireDateChange',
|
'click .expireDate' : 'onExpireDateChange',
|
||||||
'change .datepicker': 'onChangeExpirationDate',
|
'change .datepicker': 'onChangeExpirationDate',
|
||||||
'click .datepicker' : 'showDatePicker',
|
'click .datepicker' : 'showDatePicker',
|
||||||
|
// note
|
||||||
'click .share-add': 'showNoteForm',
|
'click .share-add': 'showNoteForm',
|
||||||
'click .share-note-delete': 'deleteNote',
|
'click .share-note-delete': 'deleteNote',
|
||||||
'click .share-note-submit': 'updateNote'
|
'click .share-note-submit': 'updateNote'
|
||||||
|
@ -253,20 +290,26 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if($checkBox.is(':checked')) {
|
if($checkBox.is(':checked')) {
|
||||||
if(this.configModel.get('enforcePasswordForPublicLink') === false && this.configModel.get('enableLinkPasswordByDefault') === false) {
|
if(this.configModel.get('enforcePasswordForPublicLink') === false) {
|
||||||
$loading.removeClass('hidden');
|
$loading.removeClass('hidden');
|
||||||
// this will create it
|
// this will create it
|
||||||
this.model.saveLinkShare();
|
this.model.saveLinkShare();
|
||||||
|
$('.share-menu .icon-more').click();
|
||||||
|
$('.share-menu .icon-more + .popovermenu .clipboardButton').click();
|
||||||
} else {
|
} else {
|
||||||
this.$el.find('.linkPass').slideToggle(OC.menuSpeed);
|
// force the rendering of the menu
|
||||||
this.$el.find('.linkPassText').focus();
|
this.showPending = true;
|
||||||
|
this.render()
|
||||||
|
$('.share-menu .icon-more').click();
|
||||||
|
$('.share-menu .icon-more + .popovermenu input:eq(1)').focus()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.model.get('linkShare').isLinkShare) {
|
if (this.model.get('linkShare').isLinkShare) {
|
||||||
$loading.removeClass('hidden');
|
$loading.removeClass('hidden');
|
||||||
this.model.removeLinkShare();
|
this.model.removeLinkShare();
|
||||||
} else {
|
} else {
|
||||||
this.$el.find('.linkPass').slideToggle(OC.menuSpeed);
|
this.showPending = false;
|
||||||
|
this.render()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -389,7 +432,6 @@
|
||||||
var $menu = $element.closest('li');
|
var $menu = $element.closest('li');
|
||||||
var $form = $menu.next('li.share-note-form');
|
var $form = $menu.next('li.share-note-form');
|
||||||
|
|
||||||
console.log($form.find('.share-note'));
|
|
||||||
$form.find('.share-note').val('');
|
$form.find('.share-note').val('');
|
||||||
|
|
||||||
$form.addClass('hidden');
|
$form.addClass('hidden');
|
||||||
|
@ -492,6 +534,8 @@
|
||||||
|
|
||||||
var isLinkShare = this.model.get('linkShare').isLinkShare;
|
var isLinkShare = this.model.get('linkShare').isLinkShare;
|
||||||
var isPasswordSet = !!this.model.get('linkShare').password;
|
var isPasswordSet = !!this.model.get('linkShare').password;
|
||||||
|
var isPasswordEnforced = this.configModel.get('enforcePasswordForPublicLink')
|
||||||
|
var isPasswordEnabledByDefault = this.configModel.get('enableLinkPasswordByDefault') === true
|
||||||
var showPasswordCheckBox = isLinkShare
|
var showPasswordCheckBox = isLinkShare
|
||||||
&& ( !this.configModel.get('enforcePasswordForPublicLink')
|
&& ( !this.configModel.get('enforcePasswordForPublicLink')
|
||||||
|| !this.model.get('linkShare').password);
|
|| !this.model.get('linkShare').password);
|
||||||
|
@ -565,7 +609,7 @@
|
||||||
passwordLabel: t('core', 'Password'),
|
passwordLabel: t('core', 'Password'),
|
||||||
passwordPlaceholder: isPasswordSet ? PASSWORD_PLACEHOLDER : PASSWORD_PLACEHOLDER_MESSAGE,
|
passwordPlaceholder: isPasswordSet ? PASSWORD_PLACEHOLDER : PASSWORD_PLACEHOLDER_MESSAGE,
|
||||||
passwordPlaceholderInitial: passwordPlaceholderInitial,
|
passwordPlaceholderInitial: passwordPlaceholderInitial,
|
||||||
isPasswordSet: isPasswordSet,
|
isPasswordSet: isPasswordSet || isPasswordEnabledByDefault || isPasswordEnforced,
|
||||||
showPasswordCheckBox: showPasswordCheckBox,
|
showPasswordCheckBox: showPasswordCheckBox,
|
||||||
publicUpload: publicUpload && isLinkShare,
|
publicUpload: publicUpload && isLinkShare,
|
||||||
publicEditing: publicEditable,
|
publicEditing: publicEditable,
|
||||||
|
@ -587,12 +631,23 @@
|
||||||
expirationDatePlaceholder: t('core', 'Expiration date'),
|
expirationDatePlaceholder: t('core', 'Expiration date'),
|
||||||
hasExpireDate: hasExpireDate,
|
hasExpireDate: hasExpireDate,
|
||||||
isExpirationEnforced: isExpirationEnforced,
|
isExpirationEnforced: isExpirationEnforced,
|
||||||
|
isPasswordEnforced: isPasswordEnforced,
|
||||||
expireDate: expireDate,
|
expireDate: expireDate,
|
||||||
defaultExpireDate: moment().add(1, 'day').format('DD-MM-YYYY'), // Can't expire today
|
defaultExpireDate: moment().add(1, 'day').format('DD-MM-YYYY'), // Can't expire today
|
||||||
shareNote: this.model.get('linkShare').note,
|
shareNote: this.model.get('linkShare').note,
|
||||||
addNoteLabel: t('core', 'Note to recipient'),
|
addNoteLabel: t('core', 'Note to recipient'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var pendingPopover = this.pendingPopoverMenuTemplate({
|
||||||
|
cid: this.model.get('linkShare').id,
|
||||||
|
enablePasswordLabel: t('core', 'Password protect'),
|
||||||
|
passwordLabel: t('core', 'Password'),
|
||||||
|
passwordPlaceholder: isPasswordSet ? PASSWORD_PLACEHOLDER : PASSWORD_PLACEHOLDER_MESSAGE,
|
||||||
|
passwordPlaceholderInitial: passwordPlaceholderInitial,
|
||||||
|
showPasswordCheckBox: showPasswordCheckBox,
|
||||||
|
isPasswordEnforced: isPasswordEnforced,
|
||||||
|
});
|
||||||
|
|
||||||
this.$el.html(linkShareTemplate({
|
this.$el.html(linkShareTemplate({
|
||||||
cid: this.model.get('linkShare').id,
|
cid: this.model.get('linkShare').id,
|
||||||
shareAllowed: true,
|
shareAllowed: true,
|
||||||
|
@ -600,6 +655,9 @@
|
||||||
linkShareLabel: t('core', 'Share link'),
|
linkShareLabel: t('core', 'Share link'),
|
||||||
linkShareEnableLabel: t('core', 'Enable'),
|
linkShareEnableLabel: t('core', 'Enable'),
|
||||||
popoverMenu: popover,
|
popoverMenu: popover,
|
||||||
|
pendingPopoverMenu: pendingPopover,
|
||||||
|
showMenu: isLinkShare || this.showPending,
|
||||||
|
showPending: this.showPending && !isLinkShare
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.delegateEvents();
|
this.delegateEvents();
|
||||||
|
@ -645,6 +703,19 @@
|
||||||
return this._popoverMenuTemplate(data);
|
return this._popoverMenuTemplate(data);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* renders the pending popover template and returns the resulting HTML
|
||||||
|
*
|
||||||
|
* @param {Object} data
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
pendingPopoverMenuTemplate: function(data) {
|
||||||
|
if(!this._pendingPopoverMenuTemplate) {
|
||||||
|
this._pendingPopoverMenuTemplate = Handlebars.compile(TEMPLATE_POPOVER_MENU_PENDING);
|
||||||
|
}
|
||||||
|
return this._pendingPopoverMenuTemplate(data);
|
||||||
|
},
|
||||||
|
|
||||||
onPopUpClick: function(event) {
|
onPopUpClick: function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
@ -701,7 +772,6 @@
|
||||||
self.setExpirationDate(expireDate);
|
self.setExpirationDate(expireDate);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(event, $(expirationDatePicker));
|
|
||||||
$(expirationDatePicker).datepicker('show');
|
$(expirationDatePicker).datepicker('show');
|
||||||
$(expirationDatePicker).focus();
|
$(expirationDatePicker).focus();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue