-
Notifications
You must be signed in to change notification settings - Fork 30
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
Zhifan Created Pause User Permission #1196
base: development
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,7 +169,8 @@ const userProfileController = function (UserProfile, Project) { | |
}; | ||
|
||
const getUserProfiles = async function (req, res) { | ||
if (!(await checkPermission(req, 'getUserProfiles'))) { | ||
if (!(await checkPermission(req, 'getUserProfiles') || | ||
await checkPermission(req, 'pauseResumeUser'))) { | ||
forbidden(res, 'You are not authorized to view all users'); | ||
return; | ||
} | ||
|
@@ -1229,7 +1230,9 @@ const userProfileController = function (UserProfile, Project) { | |
); | ||
|
||
if ( | ||
!((await hasPermission(req.body.requestor, 'changeUserStatus')) && canEditProtectedAccount) | ||
!((await hasPermission(req.body.requestor, 'changeUserStatus') | ||
|| await hasPermission(req.body.requestor, 'pauseResumeUser')) | ||
&& canEditProtectedAccount) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would allow 'pauseResumeUser' to also do what 'changeUserStatus' can do (setting final day for users?). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The pauseResumeUser function does not allow users to set the final day because the “Set Final Day” button only appears when the condition The changeUserStatus function manages various user status transitions, including deactivating a user, which can occur with or without a time constraint if one is provided. It handles pausing a user, setting the final day, and directly deactivating a user. All these actions request the same endpoint to toggle the user’s status between active and inactive. Access to these different functionalities is differentiated by the frontend. In the original implementation, deactivating a user with a time constraint required multiple permissions. For potential security concerns, the pause user functionality has been fully isolated from this function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Fantastic, thank you.
I only raised the concern because people can use tools like Postman to circumvent the front-end limitations and manually construct the API requests. Your solution is the perfect fix for this. |
||
) { | ||
if (PROTECTED_EMAIL_ACCOUNT.includes(req.body.requestor.email)) { | ||
logger.logInfo( | ||
|
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.
You could have someone without 'getUserProfiles' where you only want them to be able to pause people on their team or people otherwise accessible without needing access to everyone.
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.
Team leaders should not be able to pause people on their team. Confirmed with Jae that people with permission to pause anyone should have access to the user management page, which fetches all users.