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

GeneralManager is able to add users to WM- #861

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zak39
Copy link
Collaborator

@zak39 zak39 commented Jun 16, 2023

If the "share with gorup members only" is checked, the GeneralManager is not able to add users to the Workspace Manager group.

@smarinier, don't accept my PR for the moment, please 🙏

I didn't test it yet ^^'

If the "share with gorup members only" is checked, the GeneralManager is
not able to add users to the Workspace Manager group.

Signed-off-by: Baptiste Fotia <[email protected]>
@zak39 zak39 added backend Modification related to backend important bug Should be treated after Major bugs draft Don't accept the PR labels Jun 16, 2023
@zak39 zak39 requested a review from smarinier June 16, 2023 13:29
@zak39 zak39 self-assigned this Jun 16, 2023
@smarinier
Copy link
Collaborator

Oui, mon point avec Philippe était justement une Optimisation. On est bien d'accord que ce cas à tester est très rare. Avec le test "en amont" de getUsersFromGroupsOnly, tu 'loades' les groupes de l'utilisateur deux fois (si ce n'est pas un GM, donc dans la majorité des cas).

Une pour tester si c'est un GM, puis après dans getUsersFromGroupsOnly, la première chose que l'on fait c'est getUserGroups() (donc la même chose).

Il suffirait peut être de tester que GENERAL_MANAGER n'est pas dans les groupes obtenus. Et donc de faire le filtrage dans la fonction, pour que ce soit sans impact de performance

@smarinier
Copy link
Collaborator

En complément, je changerais le nom de "getUsersFromGroupsOnly", car il n'est pas exact qu'il fasse un "get", vu qu'il reçoit des $users qu'il renvoie identiquement ou diminué, en "filterUsersFromGroupsOnly"

Et voici ce que je mettrais (après $groupsOfUserSession = ...)

	// don't filter users for GeneralManagers
	if (array_reduce($groupsOfUserSession, function (bool $isWSMgr, IGroup $group) {
		return $isWSMgr ? true : $group->getGID() === ManagersWorkspace::GENERAL_MANAGER;
	}, false)) {
		return $users;
	}

(cf la discussion précédente : bouger le test "isGeneralManager" dans la fonction getUsers...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Modification related to backend draft Don't accept the PR important bug Should be treated after Major bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants