refactor(task-sort-order): optimize access check and clean up code
- Improved the access check logic by incorporating team member validation in the SQL query, enhancing security and accuracy. - Removed unnecessary whitespace for cleaner code formatting. - Updated socket event emission for consistency in response structure.
This commit is contained in:
@@ -82,11 +82,11 @@ const onTaskSortOrderChange = async (io: Server, socket: Socket, data: ChangeReq
|
||||
const dependencyResult = await dbPool.query(`
|
||||
SELECT EXISTS(
|
||||
SELECT 1 FROM project_members pm
|
||||
INNER JOIN projects p ON p.id = pm.project_id
|
||||
WHERE pm.project_id = $1
|
||||
AND pm.user_id = $2
|
||||
AND p.team_id = $3
|
||||
AND pm.is_active = true
|
||||
INNER JOIN projects p ON p.id = pm.project_id
|
||||
INNER JOIN team_members tm ON pm.team_member_id = tm.id
|
||||
WHERE pm.project_id = $1
|
||||
AND tm.user_id = $2
|
||||
AND p.team_id = $3
|
||||
) as has_access
|
||||
`, [project_id, userId, team_id]);
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
DragStartEvent,
|
||||
DragEndEvent,
|
||||
DragOverEvent,
|
||||
closestCorners,
|
||||
KeyboardSensor,
|
||||
PointerSensor,
|
||||
useSensor,
|
||||
@@ -20,7 +19,6 @@ import {
|
||||
import {
|
||||
SortableContext,
|
||||
horizontalListSortingStrategy,
|
||||
verticalListSortingStrategy,
|
||||
} from '@dnd-kit/sortable';
|
||||
import { RootState } from '@/app/store';
|
||||
import {
|
||||
@@ -34,8 +32,6 @@ import {
|
||||
fetchEnhancedKanbanLabels,
|
||||
} from '@/features/enhanced-kanban/enhanced-kanban.slice';
|
||||
import EnhancedKanbanGroup from './EnhancedKanbanGroup';
|
||||
import EnhancedKanbanTaskCard from './EnhancedKanbanTaskCard';
|
||||
import PerformanceMonitor from './PerformanceMonitor';
|
||||
import './EnhancedKanbanBoard.css';
|
||||
import { useSocket } from '@/socket/socketContext';
|
||||
import { useAppSelector } from '@/hooks/useAppSelector';
|
||||
@@ -50,6 +46,7 @@ import ImprovedTaskFilters from '../task-management/improved-task-filters';
|
||||
import { fetchStatusesCategories } from '@/features/taskAttributes/taskStatusSlice';
|
||||
import { useFilterDataLoader } from '@/hooks/useFilterDataLoader';
|
||||
import { useTaskSocketHandlers } from '@/hooks/useTaskSocketHandlers';
|
||||
import { useAuthService } from '@/hooks/useAuth';
|
||||
|
||||
// Import the TaskListFilters component
|
||||
const TaskListFilters = React.lazy(() => import('@/pages/projects/projectView/taskList/task-list-filters/task-list-filters'));
|
||||
@@ -68,7 +65,8 @@ const EnhancedKanbanBoard: React.FC<EnhancedKanbanBoardProps> = ({ projectId, cl
|
||||
performanceMetrics
|
||||
} = useSelector((state: RootState) => state.enhancedKanbanReducer);
|
||||
const { socket } = useSocket();
|
||||
const { teamId } = useAppSelector((state: RootState) => state.auth);
|
||||
const authService = useAuthService();
|
||||
const teamId = authService.getCurrentSession()?.team_id;
|
||||
const groupBy = useSelector((state: RootState) => state.enhancedKanbanReducer.groupBy);
|
||||
const project = useAppSelector((state: RootState) => state.projectReducer.project);
|
||||
const { statusCategories, status: existingStatuses } = useAppSelector((state) => state.taskStatusReducer);
|
||||
|
||||
Reference in New Issue
Block a user