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

IBX-7037: Added check if user has permission to change password #64

Merged
Merged
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
13 changes: 8 additions & 5 deletions src/bundle/Controller/UserSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Ibexa\Bundle\User\Controller;

use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Ibexa\Contracts\Core\Repository\PermissionResolver;
use Ibexa\User\ExceptionHandler\ActionResultHandler;
use Ibexa\User\Form\Data\UserSettingUpdateData;
use Ibexa\User\Form\Factory\FormFactory;
Expand Down Expand Up @@ -39,23 +39,22 @@ class UserSettingsController extends Controller
/** @var \Ibexa\User\ExceptionHandler\ActionResultHandler */
private $actionResultHandler;

/** @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface */
private $configResolver;
private PermissionResolver $permissionResolver;

public function __construct(
FormFactory $formFactory,
SubmitHandler $submitHandler,
UserSettingService $userSettingService,
ValueDefinitionRegistry $valueDefinitionRegistry,
ActionResultHandler $actionResultHandler,
ConfigResolverInterface $configResolver
PermissionResolver $permissionResolver
) {
$this->formFactory = $formFactory;
$this->submitHandler = $submitHandler;
$this->userSettingService = $userSettingService;
$this->valueDefinitionRegistry = $valueDefinitionRegistry;
$this->actionResultHandler = $actionResultHandler;
$this->configResolver = $configResolver;
$this->permissionResolver = $permissionResolver;
}

/**
Expand All @@ -67,9 +66,13 @@ public function __construct(
*/
public function listAction(int $page = 1): ListView
{
$user = $this->getUser()->getAPIUser();
$canChangePassword = $this->permissionResolver->canUser('user', 'password', $user);

return new ListView(null, [
'grouped_settings' => $this->userSettingService->loadGroupedUserSettings(),
'value_definitions' => $this->valueDefinitionRegistry->getValueDefinitions(),
'can_change_password' => $canChangePassword,
]);
}

Expand Down
Loading