Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable/Disable users to change their password #77

Closed
wants to merge 5 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pipeline:
image: nextcloudci/php7.0:php7.0-2
environment:
- APP_NAME=password_policy
- CORE_BRANCH=master
- CORE_BRANCH=stable15
- DB=sqlite
commands:
- wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ php:

env:
global:
- CORE_BRANCH=master
- CORE_BRANCH=stable15
- APP_NAME=password_policy
matrix:
- DB=sqlite
Expand Down
8 changes: 8 additions & 0 deletions js/settings-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,12 @@ $(document).ready(function(){
passwordPolicy.saveMinLength($(this).val());
});

$('#password-change').click(function() {
var value = '0';
if (this.checked) {
value = '1';
}
OCP.AppConfig.setValue('password_policy', 'passwordChange', value);
});

});
25 changes: 25 additions & 0 deletions lib/PasswordPolicyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,29 @@ public function setEnforceHaveIBeenPwned(bool $enforceHaveIBeenPwned) {
$this->config->setAppValue('password_policy', 'enforceHaveIBeenPwned', $enforceHaveIBeenPwned ? '1' : '0');
}

/**
*Get method for password change
*
*@return bool
*/

public function getPasswordChange(): bool {
return $this->config->getAppValue(
'password_policy',
'passwordChange',
'0'
) === '1';
}

/**
* Enable/Disable users to change their password
*
*@param bool $passwordChange
*/

public function setPasswordChange(bool $passwordChange) {
$this->config->setAppValue('password_policy', 'passwordChange', $passwordChange ? '1' : '0');
}


}
1 change: 1 addition & 0 deletions lib/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function getForm(): TemplateResponse {
'enforceNumericCharacters' => $this->config->getEnforceNumericCharacters(),
'enforceSpecialCharacters' => $this->config->getEnforceSpecialCharacters(),
'enforceHaveIBeenPwned' => $this->config->getEnforceHaveIBeenPwned(),
'passwordChange' => $this->config->getPasswordChange(),
]);

return $response;
Expand Down
5 changes: 5 additions & 0 deletions templates/settings-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,9 @@
<p class="password-policy-settings-hint">
<?php p($l->t('This check creates a hash of the password and sends the first 5 characters of this hash to the haveibeenpwned.com API to retrieve a list of all hashes that start with those. Then it checks on the Nextcloud instance if the password hash is in the result set.'));?>
</p>
<p id="passwordChange">
<input type="checkbox" name="password-change" id="password-change" class="checkbox"
value="1" <?php if ($_['passwordChange']) print_unescaped('checked="checked"');?> />
<label for="password-change"><?php p('Enable users to change their passwords');?></label><br/>
</p>
</div>