Merge pull request #4093 from nextcloud/endorse-password-protection
Endorse password protection
This commit is contained in:
commit
efb21a948e
|
@ -22,6 +22,7 @@
|
|||
defaults: {
|
||||
publicUploadEnabled: false,
|
||||
enforcePasswordForPublicLink: oc_appconfig.core.enforcePasswordForPublicLink,
|
||||
enableLinkPasswordByDefault: oc_appconfig.core.enableLinkPasswordByDefault,
|
||||
isDefaultExpireDateEnforced: oc_appconfig.core.defaultExpireDateEnforced === true,
|
||||
isDefaultExpireDateEnabled: oc_appconfig.core.defaultExpireDateEnabled === true,
|
||||
isRemoteShareAllowed: oc_appconfig.core.remoteShareAllowed,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
var PASSWORD_PLACEHOLDER = '**********';
|
||||
var PASSWORD_PLACEHOLDER_MESSAGE = t('core', 'Choose a password for the public link');
|
||||
var PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL = t('core', 'Choose a password for the public link or press enter');
|
||||
|
||||
var TEMPLATE =
|
||||
'{{#if shareAllowed}}' +
|
||||
|
@ -61,7 +62,11 @@
|
|||
' {{/if}}' +
|
||||
'<div id="linkPass" class="linkPass {{#unless isPasswordSet}}hidden{{/unless}}">' +
|
||||
' <label for="linkPassText-{{cid}}" class="hidden-visually">{{passwordLabel}}</label>' +
|
||||
' {{#if showPasswordCheckBox}}' +
|
||||
' <input id="linkPassText-{{cid}}" class="linkPassText" type="password" placeholder="{{passwordPlaceholder}}" />' +
|
||||
' {{else}}' +
|
||||
' <input id="linkPassText-{{cid}}" class="linkPassText" type="password" placeholder="{{passwordPlaceholderInitial}}" />' +
|
||||
' {{/if}}' +
|
||||
' <span class="icon-loading-small hidden"></span>' +
|
||||
'</div>' +
|
||||
'{{else}}' +
|
||||
|
@ -228,7 +233,7 @@
|
|||
}
|
||||
|
||||
if($checkBox.is(':checked')) {
|
||||
if(this.configModel.get('enforcePasswordForPublicLink') === false) {
|
||||
if(this.configModel.get('enforcePasswordForPublicLink') === false && this.configModel.get('enableLinkPasswordByDefault') === false) {
|
||||
$loading.removeClass('hidden');
|
||||
// this will create it
|
||||
this.model.saveLinkShare();
|
||||
|
@ -280,10 +285,20 @@
|
|||
var $input = this.$el.find('.linkPassText');
|
||||
$input.removeClass('error');
|
||||
var password = $input.val();
|
||||
|
||||
if (this.$el.find('.linkPassText').attr('placeholder') === PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL) {
|
||||
|
||||
// in IE9 the password might be the placeholder due to bugs in the placeholders polyfill
|
||||
if(password === PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL) {
|
||||
password = '';
|
||||
}
|
||||
} else {
|
||||
|
||||
// in IE9 the password might be the placeholder due to bugs in the placeholders polyfill
|
||||
if(password === '' || password === PASSWORD_PLACEHOLDER || password === PASSWORD_PLACEHOLDER_MESSAGE) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$loading
|
||||
.removeClass('hidden')
|
||||
|
@ -391,6 +406,8 @@
|
|||
var showPasswordCheckBox = isLinkShare
|
||||
&& ( !this.configModel.get('enforcePasswordForPublicLink')
|
||||
|| !this.model.get('linkShare').password);
|
||||
var passwordPlaceholderInitial = this.configModel.get('enforcePasswordForPublicLink')
|
||||
? PASSWORD_PLACEHOLDER_MESSAGE : PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL;
|
||||
|
||||
var publicEditable =
|
||||
!this.model.isFolder()
|
||||
|
@ -428,6 +445,7 @@
|
|||
enablePasswordLabel: t('core', 'Password protect'),
|
||||
passwordLabel: t('core', 'Password'),
|
||||
passwordPlaceholder: isPasswordSet ? PASSWORD_PLACEHOLDER : PASSWORD_PLACEHOLDER_MESSAGE,
|
||||
passwordPlaceholderInitial: passwordPlaceholderInitial,
|
||||
isPasswordSet: isPasswordSet,
|
||||
showPasswordCheckBox: showPasswordCheckBox,
|
||||
publicUpload: publicUpload && isLinkShare,
|
||||
|
|
|
@ -64,6 +64,7 @@ class Sharing implements ISettings {
|
|||
'shareExcludeGroups' => $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false,
|
||||
'shareExcludedGroupsList' => $excludeGroupsList,
|
||||
'publicShareDisclaimerText' => $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null),
|
||||
'enableLinkPasswordByDefault' => $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'),
|
||||
];
|
||||
|
||||
return new TemplateResponse('settings', 'admin/sharing', $parameters, '');
|
||||
|
|
|
@ -112,6 +112,9 @@ class JSConfigHelper {
|
|||
$apps_paths[$app] = \OC_App::getAppWebPath($app);
|
||||
}
|
||||
|
||||
|
||||
$enableLinkPasswordByDefault = $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no');
|
||||
$enableLinkPasswordByDefault = ($enableLinkPasswordByDefault === 'yes') ? true : false;
|
||||
$defaultExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes';
|
||||
$defaultExpireDate = $enforceDefaultExpireDate = null;
|
||||
if ($defaultExpireDateEnabled) {
|
||||
|
@ -217,6 +220,7 @@ class JSConfigHelper {
|
|||
'defaultExpireDate' => $defaultExpireDate,
|
||||
'defaultExpireDateEnforced' => $enforceDefaultExpireDate,
|
||||
'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(),
|
||||
'enableLinkPasswordByDefault' => $enableLinkPasswordByDefault,
|
||||
'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(),
|
||||
'resharingAllowed' => \OCP\Share::isResharingAllowed(),
|
||||
'remoteShareAllowed' => $outgoingServer2serverShareEnabled,
|
||||
|
|
|
@ -46,7 +46,9 @@
|
|||
<input type="checkbox" name="shareapi_allow_public_upload" id="allowPublicUpload" class="checkbox"
|
||||
value="1" <?php if ($_['allowPublicUpload'] == 'yes') print_unescaped('checked="checked"'); ?> />
|
||||
<label for="allowPublicUpload"><?php p($l->t('Allow public uploads'));?></label><br/>
|
||||
|
||||
<input type="checkbox" name="shareapi_enable_link_password_by_default" id="enableLinkPasswordByDefault" class="checkbox"
|
||||
value="1" <?php if ($_['enableLinkPasswordByDefault'] === 'yes') print_unescaped('checked="checked"'); ?> />
|
||||
<label for="enableLinkPasswordByDefault"><?php p($l->t('Always ask for a password'));?></label><br/>
|
||||
<input type="checkbox" name="shareapi_enforce_links_password" id="enforceLinkPassword" class="checkbox"
|
||||
value="1" <?php if ($_['enforceLinkPassword']) print_unescaped('checked="checked"'); ?> />
|
||||
<label for="enforceLinkPassword"><?php p($l->t('Enforce password protection'));?></label><br/>
|
||||
|
|
|
@ -104,6 +104,11 @@ class SharingTest extends TestCase {
|
|||
->method('getAppValue')
|
||||
->with('core', 'shareapi_public_link_disclaimertext', null)
|
||||
->willReturn('Lorem ipsum');
|
||||
$this->config
|
||||
->expects($this->at(12))
|
||||
->method('getAppValue')
|
||||
->with('core', 'shareapi_enable_link_password_by_default', 'no')
|
||||
->willReturn('yes');
|
||||
|
||||
$expected = new TemplateResponse(
|
||||
'settings',
|
||||
|
@ -123,6 +128,7 @@ class SharingTest extends TestCase {
|
|||
'shareExcludeGroups' => false,
|
||||
'shareExcludedGroupsList' => '',
|
||||
'publicShareDisclaimerText' => 'Lorem ipsum',
|
||||
'enableLinkPasswordByDefault' => 'yes'
|
||||
],
|
||||
''
|
||||
);
|
||||
|
@ -191,6 +197,11 @@ class SharingTest extends TestCase {
|
|||
->method('getAppValue')
|
||||
->with('core', 'shareapi_public_link_disclaimertext', null)
|
||||
->willReturn('Lorem ipsum');
|
||||
$this->config
|
||||
->expects($this->at(12))
|
||||
->method('getAppValue')
|
||||
->with('core', 'shareapi_enable_link_password_by_default', 'no')
|
||||
->willReturn('yes');
|
||||
|
||||
$expected = new TemplateResponse(
|
||||
'settings',
|
||||
|
@ -210,6 +221,7 @@ class SharingTest extends TestCase {
|
|||
'shareExcludeGroups' => true,
|
||||
'shareExcludedGroupsList' => 'NoSharers|OtherNoSharers',
|
||||
'publicShareDisclaimerText' => 'Lorem ipsum',
|
||||
'enableLinkPasswordByDefault' => 'yes'
|
||||
],
|
||||
''
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue