Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Disable "Enforce password protection" if not asking for a password
"Enforce password protection" is a subcase of "Always ask for a
password", so it should be disabled if its parent option is unchecked.
Although other dependant options in the sharing settings are fully
hidden instead of just disabled this option is disabled but shown to
avoid confusion when updating from a previous Nextcloud version where
"Always ask for a password" was unchecked and "Enforce password
protection" was checked.

Besides that, due to their dependency the enforced password protection
is now automatically unchecked too if its parent option is unchecked.

Finally, the groups excluded from password requirements are also
disabled when "Always ask for a password" is unchecked, as they might be
still shown if "Enforce password protection" was checked due to an
update from a previous version.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu authored and nickvergessen committed May 22, 2023
commit 2c1a1b1779bb229b47652e0a15c0885dbacc1e87
15 changes: 15 additions & 0 deletions apps/settings/src/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ window.addEventListener('DOMContentLoaded', () => {
$('#setDefaultRemoteExpireDate').toggleClass('hidden', !this.checked)
})

$('#enableLinkPasswordByDefault').change(function() {
if (this.checked) {
$('#enforceLinkPassword').removeAttr('disabled')
$('#passwordsExcludedGroups').removeAttr('disabled')
} else {
$('#enforceLinkPassword').attr('disabled', '')
$('#passwordsExcludedGroups').attr('disabled', '')

// Uncheck "Enforce password protection" when "Always asks for a
// password" is unchecked; the change event needs to be explicitly
// triggered so it behaves like a change done by the user.
$('#enforceLinkPassword').removeAttr('checked').trigger('change')
}
})

$('#enforceLinkPassword').change(function() {
$('#selectPasswordsExcludedGroups').toggleClass('hidden', !this.checked)
})
Expand Down
6 changes: 5 additions & 1 deletion apps/settings/templates/settings/admin/sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,18 @@
<input type="checkbox" name="shareapi_enforce_links_password" id="enforceLinkPassword" class="checkbox"
value="1" <?php if ($_['enforceLinkPassword']) {
print_unescaped('checked="checked"');
} ?> <?php if ($_['enableLinkPasswordByDefault'] !== 'yes') {
print_unescaped('disabled');
} ?> />
<label for="enforceLinkPassword" class="indent"><?php p($l->t('Enforce password protection'));?></label><br/>

<?php if ($_['passwordExcludedGroupsFeatureEnabled']) { ?>
<span id="selectPasswordsExcludedGroups" class="double-indent <?php if (!$_['enforceLinkPassword']) { p('hidden'); } ?>">
<label for="shareapi_enforce_links_password_excluded_groups"><?php p($l->t('Exclude groups from password requirements:'));?></label><br/>
<input name="shareapi_enforce_links_password_excluded_groups" id="passwordsExcludedGroups" value="<?php p($_['passwordExcludedGroups']) ?>"
style="width: 400px" class="noJSAutoUpdate double-indent"/>
style="width: 400px" class="noJSAutoUpdate double-indent" <?php if ($_['enableLinkPasswordByDefault'] !== 'yes') {
print_unescaped('disabled');
} ?> />
</span><br/>
<?php } ?>

Expand Down