Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 7 additions & 1 deletion lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class SettingsController extends Controller implements ISettings {
'spv_expiration_password_value' => 7,
'spv_expiration_nopassword_checked' => false,
'spv_expiration_nopassword_value' => 7,
'spv_apply_to_users_checked' => 'true',
'spv_apply_to_links_checked' => 'true',
];

/**
Expand Down Expand Up @@ -97,7 +99,11 @@ public function updatePolicy() {
$this->config->setAppValue('password_policy', $key, $this->request->getParam($key));
}
} else {
$this->config->setAppValue('password_policy', $key, $default);
if (\substr($key, -8) === '_checked') {
$this->config->setAppValue('password_policy', $key, false);
} else {
$this->config->setAppValue('password_policy', $key, $default);
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions lib/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ public function verifyPassword($password, $uid = null, $type = 'user') {
return;
}

// skip complexity rules if this type is not in scope
if ($type === 'user' && !$this->yes('spv_apply_to_users_checked')) {
if ($uid !== null && $this->yes('spv_password_history_checked')) {
$val = (int) $this->configValues['spv_password_history_value'];
$dbMapper = new OldPasswordMapper($this->db);
$r = new PasswordHistory($this->l10n, $dbMapper, $this->hasher);
$r->verify($password, $val, $uid);
}
return;
}
if ($this->yes('spv_min_chars_checked')) {
$val = (int) $this->configValues['spv_min_chars_value'];
$r = new Length($this->l10n);
Expand Down
12 changes: 12 additions & 0 deletions templates/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@
<p>
<?php p($l->t('Minimum password requirements for user accounts and public links:'));?>
</p>
<ul>
<li>
<label>
<input type="checkbox" name="spv_apply_to_users_checked" <?php if ($_['spv_apply_to_users_checked']): ?> checked="checked"<?php endif; ?>> <?php p($l->t('Apply to user account passwords'));?>
</label>
</li>
<li>
<label>
<input type="checkbox" name="spv_apply_to_links_checked" <?php if ($_['spv_apply_to_links_checked']): ?> checked="checked"<?php endif; ?>> <?php p($l->t('Apply to public link passwords'));?>
</label>
</li>
</ul>
<ul>
<li>
<label>
Expand Down