Merge pull request #4015 from Icinga/feature/no-user-password-changes-3286

New permission `no-user/password-change`
This commit is contained in:
Johannes Meyer 2019-12-05 13:37:13 +01:00 committed by GitHub
commit 51b05ce39a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 11 deletions

View File

@ -43,17 +43,19 @@ class AccountController extends Controller
$config = Config::app()->getSection('global');
$user = $this->Auth()->getUser();
if ($user->getAdditional('backend_type') === 'db') {
try {
$userBackend = UserBackend::create($user->getAdditional('backend_name'));
} catch (ConfigurationError $e) {
$userBackend = null;
}
if ($userBackend !== null) {
$changePasswordForm = new ChangePasswordForm();
$changePasswordForm
->setBackend($userBackend)
->handleRequest();
$this->view->changePasswordForm = $changePasswordForm;
if ($user->can('*') || ! $user->can('no-user/password-change')) {
try {
$userBackend = UserBackend::create($user->getAdditional('backend_name'));
} catch (ConfigurationError $e) {
$userBackend = null;
}
if ($userBackend !== null) {
$changePasswordForm = new ChangePasswordForm();
$changePasswordForm
->setBackend($userBackend)
->handleRequest();
$this->view->changePasswordForm = $changePasswordForm;
}
}
}

View File

@ -43,6 +43,10 @@ class RoleForm extends RepositoryForm
$view = $this->getView();
$this->providedPermissions['application'] = [
$helper->filterName('no-user/password-change') => [
'name' => 'no-user/password-change',
'description' => $this->translate('Prohibit password changes in the account preferences')
],
$helper->filterName('application/share/navigation') => [
'name' => 'application/share/navigation',
'description' => $this->translate('Allow to share navigation items')