-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: user profile not deleted without "Manage User Access" permission gf-449 #478
Conversation
const resourceId = (params as { id?: string }).id; | ||
const isUsersRoute = url.includes(APIPath.USERS); | ||
const isCurrentUserRoute = isUsersRoute && Number(resourceId) === user.id; | ||
|
||
if (isCurrentUserRoute) { | ||
done(); | ||
|
||
return; | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
Added logic to handle user self-accessing activity to the check user permissions hook.