Skip to content
Snippets Groups Projects
Commit d84d040d authored by Vincent Petry's avatar Vincent Petry Committed by GitHub
Browse files

Merge pull request #26376 from tbenk/endorse-password-for-share-link

feature endorse password for share links
parents 8c1b2528 f677acd6
No related branches found
No related tags found
No related merge requests found
...@@ -64,6 +64,9 @@ $outgoingServer2serverShareEnabled = $config->getAppValue('files_sharing', 'outg ...@@ -64,6 +64,9 @@ $outgoingServer2serverShareEnabled = $config->getAppValue('files_sharing', 'outg
$countOfDataLocation = 0; $countOfDataLocation = 0;
$value = $config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no');
$enableLinkPasswordByDefault = ($value === 'yes') ? true : false;
$dataLocation = str_replace(OC::$SERVERROOT .'/', '', $config->getSystemValue('datadirectory', ''), $countOfDataLocation); $dataLocation = str_replace(OC::$SERVERROOT .'/', '', $config->getSystemValue('datadirectory', ''), $countOfDataLocation);
if($countOfDataLocation !== 1 || !OC_User::isAdminUser(OC_User::getUser())){ if($countOfDataLocation !== 1 || !OC_User::isAdminUser(OC_User::getUser())){
$dataLocation = false; $dataLocation = false;
...@@ -159,6 +162,7 @@ $array = [ ...@@ -159,6 +162,7 @@ $array = [
'defaultExpireDate' => $defaultExpireDate, 'defaultExpireDate' => $defaultExpireDate,
'defaultExpireDateEnforced' => $enforceDefaultExpireDate, 'defaultExpireDateEnforced' => $enforceDefaultExpireDate,
'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(), 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(),
'enableLinkPasswordByDefault' => $enableLinkPasswordByDefault,
'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(), 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(),
'resharingAllowed' => \OCP\Share::isResharingAllowed(), 'resharingAllowed' => \OCP\Share::isResharingAllowed(),
'remoteShareAllowed' => $outgoingServer2serverShareEnabled, 'remoteShareAllowed' => $outgoingServer2serverShareEnabled,
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
defaults: { defaults: {
publicUploadEnabled: false, publicUploadEnabled: false,
enforcePasswordForPublicLink: oc_appconfig.core.enforcePasswordForPublicLink, enforcePasswordForPublicLink: oc_appconfig.core.enforcePasswordForPublicLink,
enableLinkPasswordByDefault: oc_appconfig.core.enableLinkPasswordByDefault,
isDefaultExpireDateEnforced: oc_appconfig.core.defaultExpireDateEnforced === true, isDefaultExpireDateEnforced: oc_appconfig.core.defaultExpireDateEnforced === true,
isDefaultExpireDateEnabled: oc_appconfig.core.defaultExpireDateEnabled === true, isDefaultExpireDateEnabled: oc_appconfig.core.defaultExpireDateEnabled === true,
isRemoteShareAllowed: oc_appconfig.core.remoteShareAllowed, isRemoteShareAllowed: oc_appconfig.core.remoteShareAllowed,
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
var PASSWORD_PLACEHOLDER = '**********'; var PASSWORD_PLACEHOLDER = '**********';
var PASSWORD_PLACEHOLDER_MESSAGE = t('core', 'Choose a password for the public link'); 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 = var TEMPLATE =
'{{#if shareAllowed}}' + '{{#if shareAllowed}}' +
...@@ -40,7 +41,11 @@ ...@@ -40,7 +41,11 @@
' {{/if}}' + ' {{/if}}' +
'<div id="linkPass" class="linkPass {{#unless isPasswordSet}}hidden{{/unless}}">' + '<div id="linkPass" class="linkPass {{#unless isPasswordSet}}hidden{{/unless}}">' +
' <label for="linkPassText-{{cid}}" class="hidden-visually">{{passwordLabel}}</label>' + ' <label for="linkPassText-{{cid}}" class="hidden-visually">{{passwordLabel}}</label>' +
' {{#if showPasswordCheckBox}}' +
' <input id="linkPassText-{{cid}}" class="linkPassText" type="password" placeholder="{{passwordPlaceholder}}" />' + ' <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>' + ' <span class="icon-loading-small hidden"></span>' +
'</div>' + '</div>' +
'{{else}}' + '{{else}}' +
...@@ -157,7 +162,7 @@ ...@@ -157,7 +162,7 @@
} }
if($checkBox.is(':checked')) { if($checkBox.is(':checked')) {
if(this.configModel.get('enforcePasswordForPublicLink') === false) { if(this.configModel.get('enforcePasswordForPublicLink') === false && this.configModel.get('enableLinkPasswordByDefault') === false) {
$loading.removeClass('hidden'); $loading.removeClass('hidden');
// this will create it // this will create it
this.model.saveLinkShare(); this.model.saveLinkShare();
...@@ -207,9 +212,19 @@ ...@@ -207,9 +212,19 @@
var $input = this.$el.find('.linkPassText'); var $input = this.$el.find('.linkPassText');
$input.removeClass('error'); $input.removeClass('error');
var password = $input.val(); var password = $input.val();
// in IE9 the password might be the placeholder due to bugs in the placeholders polyfill
if(password === '' || password === PASSWORD_PLACEHOLDER || password === PASSWORD_PLACEHOLDER_MESSAGE) { if (this.$el.find('.linkPassText').attr('placeholder') === PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL) {
return;
// 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 $loading
...@@ -277,6 +292,8 @@ ...@@ -277,6 +292,8 @@
var showPasswordCheckBox = isLinkShare var showPasswordCheckBox = isLinkShare
&& ( !this.configModel.get('enforcePasswordForPublicLink') && ( !this.configModel.get('enforcePasswordForPublicLink')
|| !this.model.get('linkShare').password); || !this.model.get('linkShare').password);
var passwordPlaceholderInitial = this.configModel.get('enforcePasswordForPublicLink')
? PASSWORD_PLACEHOLDER_MESSAGE : PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL;
this.$el.html(linkShareTemplate({ this.$el.html(linkShareTemplate({
cid: this.cid, cid: this.cid,
...@@ -288,6 +305,7 @@ ...@@ -288,6 +305,7 @@
enablePasswordLabel: t('core', 'Password protect'), enablePasswordLabel: t('core', 'Password protect'),
passwordLabel: t('core', 'Password'), passwordLabel: t('core', 'Password'),
passwordPlaceholder: isPasswordSet ? PASSWORD_PLACEHOLDER : PASSWORD_PLACEHOLDER_MESSAGE, passwordPlaceholder: isPasswordSet ? PASSWORD_PLACEHOLDER : PASSWORD_PLACEHOLDER_MESSAGE,
passwordPlaceholderInitial: passwordPlaceholderInitial,
isPasswordSet: isPasswordSet, isPasswordSet: isPasswordSet,
showPasswordCheckBox: showPasswordCheckBox, showPasswordCheckBox: showPasswordCheckBox,
publicUpload: publicUpload && isLinkShare, publicUpload: publicUpload && isLinkShare,
......
...@@ -133,6 +133,7 @@ $template->assign('suggestedOverwriteCliUrl', $suggestedOverwriteCliUrl); ...@@ -133,6 +133,7 @@ $template->assign('suggestedOverwriteCliUrl', $suggestedOverwriteCliUrl);
$template->assign('allowLinks', $config->getAppValue('core', 'shareapi_allow_links', 'yes')); $template->assign('allowLinks', $config->getAppValue('core', 'shareapi_allow_links', 'yes'));
$template->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired()); $template->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired());
$template->assign('enableLinkPasswordByDefault', $config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'));
$template->assign('allowPublicUpload', $config->getAppValue('core', 'shareapi_allow_public_upload', 'yes')); $template->assign('allowPublicUpload', $config->getAppValue('core', 'shareapi_allow_public_upload', 'yes'));
$template->assign('allowResharing', $config->getAppValue('core', 'shareapi_allow_resharing', 'yes')); $template->assign('allowResharing', $config->getAppValue('core', 'shareapi_allow_resharing', 'yes'));
$template->assign('allowPublicMailNotification', $config->getAppValue('core', 'shareapi_allow_public_notification', 'no')); $template->assign('allowPublicMailNotification', $config->getAppValue('core', 'shareapi_allow_public_notification', 'no'));
......
...@@ -212,6 +212,10 @@ if ($_['cronErrors']) { ...@@ -212,6 +212,10 @@ if ($_['cronErrors']) {
value="1" <?php if ($_['allowPublicUpload'] == 'yes') print_unescaped('checked="checked"'); ?> /> value="1" <?php if ($_['allowPublicUpload'] == 'yes') print_unescaped('checked="checked"'); ?> />
<label for="allowPublicUpload"><?php p($l->t('Allow public uploads'));?></label><br/> <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" <input type="checkbox" name="shareapi_enforce_links_password" id="enforceLinkPassword" class="checkbox"
value="1" <?php if ($_['enforceLinkPassword']) print_unescaped('checked="checked"'); ?> /> value="1" <?php if ($_['enforceLinkPassword']) print_unescaped('checked="checked"'); ?> />
<label for="enforceLinkPassword"><?php p($l->t('Enforce password protection'));?></label><br/> <label for="enforceLinkPassword"><?php p($l->t('Enforce password protection'));?></label><br/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment