Skip to content
Open
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 Manager/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function getUniqueToken(string $field): string
protected function createUserRole(User $user, string $webspaceKey, string $roleName): UserRole
{
/** @var RoleInterface $role */
$role = $this->roleRepository->findOneBy(['name' => $roleName]);
$role = $this->roleRepository->findOneBy(['key' => $roleName]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the pull request! It looks like this is a bug and was forgotten to be changed in #130.

Unfortunately, the new implementation might break things for users that use an older Sulu version. Therefore we need to fallback to the old behaviour like in the InitCommand:

if (\method_exists(Role::class, 'setKey')) {
/** @var RoleInterface|null $role */
$role = $roleRepository->findOneBy(['key' => $roleName, 'system' => $system]);
} else {
// can be removed when min requirement sulu 2.1
/** @var RoleInterface|null $role */
$role = $roleRepository->findOneBy(['name' => $roleName, 'system' => $system]);
}

Also, i think it would be nice to update the code and use roleKey instead of roleName as variable name in the InitCommand, UserManager and UserManagerInterface 🙂

$userRole = new UserRole();

$locales = [];
Expand Down