This commit is contained in:
alma 2025-05-11 22:15:11 +02:00
parent cb46c03db5
commit 7e632a5cf7
2 changed files with 18 additions and 1 deletions

View File

@ -30,7 +30,13 @@ async function checkAuth(request: Request, body?: any) {
}
// Fallback to system user if no creatorId provided
console.log('No creatorId provided, using system user');
return { authorized: true, userId: process.env.SYSTEM_USER_ID || 'system' };
// Use the first user in the database as system user
const systemUser = await prisma.user.findFirst();
if (!systemUser) {
console.error('No users found in database for system user fallback');
return { authorized: false, userId: null };
}
return { authorized: true, userId: systemUser.id };
}
// Fall back to NextAuth session for regular users

View File

@ -32,6 +32,17 @@ export class N8nService {
data: response.data
});
// Handle string response
if (typeof response.data === 'string') {
console.log('Received string response from n8n, treating as success');
return {
success: true,
results: {
message: response.data
}
};
}
if (response.data.errors && response.data.errors.length > 0) {
console.warn('Workflow completed with partial success:', response.data.errors);
return response.data;