Skip to content

fix(contact): do not allow kicking yourself out of the workspace - #11100

Open
MichaelUray wants to merge 1 commit into
hcengineering:developfrom
MichaelUray:fix/kick-self-guard
Open

MichaelUray wants to merge 1 commit into
hcengineering:developfrom
MichaelUray:fix/kick-self-guard

Conversation

@MichaelUray

Copy link
Copy Markdown
Contributor

Fixes #7429

Problem and change

The "Kick employee" context action had no check for the current user, so it was offered on your own employee and removed your own account from the workspace (the account service treats a self-removal as a regular leave), locking you out.

Add a CanKickEmployee visibility tester that hides the action for the current user's own employee, and make the action implementation a no-op for the current user as a second guard. Leaving a workspace remains available through "Leave workspace" in the profile settings, which also handles the last-owner case. The check is a small pure helper covered by unit tests; enable jest for contact-resources.

Tests

kickEmployee.test.ts (the package now runs its jest tests). Manual: Contacts → Employee → right-click your own employee: no "Kick employee"; another active employee still has it.

The "Kick employee" context action had no check for the current user, so it was offered on your own employee and removed your own account from the workspace (the account service treats a self-removal as a regular leave), locking you out.

Add a CanKickEmployee visibility tester that hides the action for the current user's own employee, and make the action implementation a no-op for the current user as a second guard. Leaving a workspace remains available through "Leave workspace" in the profile settings, which also handles the last-owner case. The check is a small pure helper covered by unit tests; enable jest for contact-resources.

Fixes hcengineering#7429

Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kicked out myself

1 participant