-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix: Dropitem permission #3955
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: Dropitem permission #3955
Changes from all commits
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 |
---|---|---|
|
@@ -153,7 +153,12 @@ const systemManage = { | |
chat_user_edit: () =>false, | ||
|
||
|
||
auth: () => false, | ||
auth: () => | ||
hasPermission([ | ||
RoleConst.ADMIN, | ||
PermissionConst.RESOURCE_KNOWLEDGE_AUTH | ||
],'OR' | ||
), | ||
folderCreate: () => false, | ||
folderEdit: () => false, | ||
folderDelete: () => false, | ||
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 provided code snippet seems to be setting up routes for an application with different permissions for users. However, there are several points that could be improved:
Here's a potential revision based on these considerations: const systemManage = {
// Simulated user edit feature; replace with real endpoint logic if necessary
chat_user_edit: () => { return true; }, // Replace with real implementation
// Authentication check based on role and permission requirements
auth: () => (
hasPermission(['ADMIN', 'RESOURCE_KNOWLEDGE_AUTH'], 'OR')
),
// Folder management functions
folderCreate: () => false,
folderEdit: () =>false,
folderDelete: () => false,
// Additional fields can include more routing and functionality
}; Make sure |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,14 @@ const systemManage = { | |
'OR', | ||
), | ||
|
||
auth: () => false, | ||
auth: () => | ||
hasPermission( | ||
[ | ||
RoleConst.ADMIN, | ||
PermissionConst.RESOURCE_TOOL_AUTH, | ||
], | ||
'OR', | ||
), | ||
folderCreate: () => false, | ||
folderEdit: () => false, | ||
folderDelete: () => false, | ||
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 provided JavaScript function checks if a user is authenticated based on their permissions in the Here’s a suggested revision: @@ -57,13 +62,26 @@ const systemManage = {
'OR',
),
- auth: () => false,
+ auth: (requiredActions) => {
+ // Example of checking if user has required roles/permissions
+ return hasPermission(
+ [
+ RoleConst.ADMIN,
+ PermissionConst.ACCESS_FOLDERS,
+ ...requiredActions.map(action => PermissionConst[`${action.toUpperCase}_AUTH`]),
+ ],
+ 'OR',
+ );
+ },
folderCreate: () => systemManage.auth(['CREATE']),
folderEdit: () => systemManage.auth(['EDIT']),
folderDelete: () => systemManage.auth(['DELETE']),
}; Key Changes:
This refactoring will allow more flexibility and clarity in determining authentication status for various actions related to managing files/folders. Remember to adjust the |
||
|
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.
The provided code seems to contain a few issues:
Unnecessary Parentheses: The function parameters in the
auth
method are enclosed in parentheses unnecessarily. This is not required in JavaScript.Redundant Spaces and Lines: There are multiple spaces between words and lines that can be removed for better readability.
Indentation: Ensure consistent indentation throughout the code for clarity.
Here's a revised version of the code with these improvements applied:
Key Changes:
and
andor
functions.These adjustments make the code more readable and maintainable.