feat(Task): implement user ownership for tasks and enhance related services
- Added ownerId field to Task model to associate tasks with users. - Updated TaskService methods to enforce user ownership in task operations. - Enhanced API routes to include user authentication and ownership checks. - Modified DailyService and analytics services to filter tasks by user. - Integrated user session handling in various components for personalized task management.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { tasksService } from '@/services/task-management/tasks';
|
||||
import { getServerSession } from 'next-auth';
|
||||
import { authOptions } from '@/lib/auth';
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
@@ -15,7 +17,16 @@ export async function GET(
|
||||
);
|
||||
}
|
||||
|
||||
const checkboxes = await tasksService.getTaskRelatedCheckboxes(id);
|
||||
// Vérifier l'authentification
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user?.id) {
|
||||
return NextResponse.json({ error: 'Non authentifié' }, { status: 401 });
|
||||
}
|
||||
|
||||
const checkboxes = await tasksService.getTaskRelatedCheckboxes(
|
||||
session.user.id,
|
||||
id
|
||||
);
|
||||
|
||||
return NextResponse.json({ data: checkboxes });
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user