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'); $config = Config::app()->getSection('global');
$user = $this->Auth()->getUser(); $user = $this->Auth()->getUser();
if ($user->getAdditional('backend_type') === 'db') { if ($user->getAdditional('backend_type') === 'db') {
try { if ($user->can('*') || ! $user->can('no-user/password-change')) {
$userBackend = UserBackend::create($user->getAdditional('backend_name')); try {
} catch (ConfigurationError $e) { $userBackend = UserBackend::create($user->getAdditional('backend_name'));
$userBackend = null; } catch (ConfigurationError $e) {
} $userBackend = null;
if ($userBackend !== null) { }
$changePasswordForm = new ChangePasswordForm(); if ($userBackend !== null) {
$changePasswordForm $changePasswordForm = new ChangePasswordForm();
->setBackend($userBackend) $changePasswordForm
->handleRequest(); ->setBackend($userBackend)
$this->view->changePasswordForm = $changePasswordForm; ->handleRequest();
$this->view->changePasswordForm = $changePasswordForm;
}
} }
} }

View File

@ -43,6 +43,10 @@ class RoleForm extends RepositoryForm
$view = $this->getView(); $view = $this->getView();
$this->providedPermissions['application'] = [ $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') => [ $helper->filterName('application/share/navigation') => [
'name' => 'application/share/navigation', 'name' => 'application/share/navigation',
'description' => $this->translate('Allow to share navigation items') 'description' => $this->translate('Allow to share navigation items')