feat: enhance TFS and Jira field tests with user-specific configurations
- Updated `testJiraFields` and `testStoryPoints` to accept a `userId` from command line arguments, allowing for user-specific Jira configurations. - Modified TFS sync and test routes to include user authentication checks and pass the logged-in user's ID for task synchronization and connection testing. - Refactored `TfsService` methods to utilize user-specific configurations, improving flexibility and accuracy in TFS operations.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { tfsService } from '@/services/integrations/tfs';
|
||||
import { getServerSession } from 'next-auth';
|
||||
import { authOptions } from '@/lib/auth';
|
||||
|
||||
/**
|
||||
* Route GET /api/tfs/test
|
||||
@@ -7,10 +9,18 @@ import { tfsService } from '@/services/integrations/tfs';
|
||||
*/
|
||||
export async function GET() {
|
||||
try {
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user?.id) {
|
||||
return NextResponse.json(
|
||||
{ success: false, error: 'Non authentifié' },
|
||||
{ status: 401 }
|
||||
);
|
||||
}
|
||||
|
||||
console.log('🔄 Test de connexion TFS...');
|
||||
|
||||
// Valider la configuration via le service singleton
|
||||
const configValidation = await tfsService.validateConfig();
|
||||
// Valider la configuration via le service singleton avec l'utilisateur connecté
|
||||
const configValidation = await tfsService.validateConfig(session.user.id);
|
||||
if (!configValidation.valid) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -22,8 +32,8 @@ export async function GET() {
|
||||
);
|
||||
}
|
||||
|
||||
// Tester la connexion
|
||||
const isConnected = await tfsService.testConnection();
|
||||
// Tester la connexion avec l'utilisateur connecté
|
||||
const isConnected = await tfsService.testConnection(session.user.id);
|
||||
|
||||
if (isConnected) {
|
||||
// Test approfondi : récupérer des métadonnées
|
||||
|
||||
Reference in New Issue
Block a user