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

fix: user profile not deleted without "Manage User Access" permission gf-449 #478

Merged
merged 8 commits into from
Sep 24, 2024

Conversation

Vitaliistf
Copy link
Collaborator

@Vitaliistf Vitaliistf commented Sep 23, 2024

Added logic to handle user self-accessing activity to the check user permissions hook.

Comment on lines 19 to 27
const resourceId = (params as { id?: string }).id;
const isUsersRoute = url.includes(APIPath.USERS);
const isCurrentUserRoute = isUsersRoute && Number(resourceId) === user.id;

if (isCurrentUserRoute) {
done();

return;
}
Copy link
Collaborator

@liza-veis liza-veis Sep 23, 2024

Choose a reason for hiding this comment

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

This logic shouldn't be in checkUserPermissions hook. This hook is for common permission case and should now nothing about specific routes and their logic. Instead let's use DELETE /authenticated-user and PATCH /authenticated-user in auth controller for current user, and move the logic related to this routes to auth module

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually let's do it simpler and user DELETE /users, PATCH /users to update or delete current user

Copy link
Collaborator Author

@Vitaliistf Vitaliistf Sep 23, 2024

Choose a reason for hiding this comment

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

So, you mean, user that wants to delete/update his own account now should send a request without id, and the admin that wants to delete other user should use id (permissions will be checked of course), right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes

@what1s1ove what1s1ove merged commit 5e017f5 into main Sep 24, 2024
6 checks passed
This was referenced Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

4 participants