Skip to content

Commit

Permalink
fixes current user access
Browse files Browse the repository at this point in the history
  • Loading branch information
Elorfin committed Dec 6, 2023
1 parent b7d9ac7 commit 4cedbd2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/main/app/Controller/Component/ContextController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public function openAction(string $context, string $contextId = null): JsonRespo
'managed' => $isManager,
'impersonated' => $isImpersonated,
'roles' => array_map(function (Role $role) {
'roles' => array_values(array_map(function (Role $role) {
return $this->serializer->serialize($role, [SerializerInterface::SERIALIZE_MINIMAL]);
}, $contextRoles),
}, $contextRoles)),
'accessErrors' => $accessErrors,

// get all enabled tools for the context, even those inaccessible to the current user
Expand Down
2 changes: 1 addition & 1 deletion src/main/app/Entity/HasContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait HasContext
/**
* @ORM\Column(name="context_id", nullable=true)
*/
private string $contextId;
private ?string $contextId = null;

public function getContextName(): string
{
Expand Down
8 changes: 4 additions & 4 deletions src/main/app/Resources/modules/security/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const actions = {}

actions.updateUser = makeActionCreator(SECURITY_USER_UPDATE, 'user')

actions.changeUser = (user, impersonated = false, administration = false) => (dispatch, getState) => {
actions.changeUser = (user, impersonated = false, contexts = []) => (dispatch, getState) => {
// we will dispatch action only if the user has really changed
// this will avoid false positive as it is used by other ui components
// to know when to invalidate/reload data for the new user
Expand All @@ -29,7 +29,7 @@ actions.changeUser = (user, impersonated = false, administration = false) => (di
type: SECURITY_USER_CHANGE,
user: user,
impersonated: impersonated,
administration: administration
contexts: contexts
})
}
}
Expand All @@ -52,7 +52,7 @@ actions.login = (username, password, rememberMe) => ({
})

actions.onLogin = (response) => (dispatch) => {
dispatch(actions.changeUser(response.user, false, response.administration))
dispatch(actions.changeUser(response.user, false, response.contexts))

if (!isEmpty(response.messages)) {
dispatch(modalActions.showModal(MODAL_CONNECTION, {
Expand All @@ -65,6 +65,6 @@ actions.logout = () => ({
[apiConst.API_REQUEST]: {
silent: true,
url: ['claro_security_logout'],
success: (response, dispatch) => dispatch(actions.changeUser(null, false, false))
success: (response, dispatch) => dispatch(actions.changeUser(null, false, []))
}
})
2 changes: 1 addition & 1 deletion src/main/core/Manager/RoleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function renameUserRole(Role $role, string $username): void
$this->om->persist($role);
}

public function getWorkspaceRoles(Workspace $workspace): ?Role
public function getWorkspaceRoles(Workspace $workspace): array
{
return $this->roleRepo->findBy(['workspace' => $workspace]);
}
Expand Down

0 comments on commit 4cedbd2

Please sign in to comment.