n8n
This commit is contained in:
parent
cb46c03db5
commit
7e632a5cf7
@ -30,7 +30,13 @@ async function checkAuth(request: Request, body?: any) {
|
|||||||
}
|
}
|
||||||
// Fallback to system user if no creatorId provided
|
// Fallback to system user if no creatorId provided
|
||||||
console.log('No creatorId provided, using system user');
|
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
|
// Fall back to NextAuth session for regular users
|
||||||
|
|||||||
@ -32,6 +32,17 @@ export class N8nService {
|
|||||||
data: response.data
|
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) {
|
if (response.data.errors && response.data.errors.length > 0) {
|
||||||
console.warn('Workflow completed with partial success:', response.data.errors);
|
console.warn('Workflow completed with partial success:', response.data.errors);
|
||||||
return response.data;
|
return response.data;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user