Agenda Sync refactor Mig Graph
This commit is contained in:
parent
901b8cd7af
commit
60c5ce8e1a
@ -3,7 +3,7 @@ import { getServerSession } from 'next-auth';
|
||||
import { authOptions } from "@/app/api/auth/options";
|
||||
import { exchangeCodeForTokens } from '@/lib/services/microsoft-oauth';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
import { testEmailConnection, saveUserEmailCredentials } from '@/lib/services/email-service';
|
||||
import { saveUserEmailCredentials } from '@/lib/services/email-service';
|
||||
import { invalidateFolderCache } from '@/lib/redis';
|
||||
import { cacheEmailCredentials } from '@/lib/redis';
|
||||
|
||||
@ -99,17 +99,6 @@ export async function POST(request: Request) {
|
||||
tokenExpiry: new Date(credentials.tokenExpiry).toISOString()
|
||||
});
|
||||
|
||||
// Test connection before saving
|
||||
console.log(`Testing Microsoft OAuth connection for user ${session.user.id}`);
|
||||
const testResult = await testEmailConnection(credentials);
|
||||
|
||||
if (!testResult.imap) {
|
||||
return NextResponse.json(
|
||||
{ error: `Connection test failed: ${testResult.error || 'Could not connect to Microsoft IMAP server'}` },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// Save credentials to database and cache
|
||||
console.log(`Saving Microsoft account for user: ${session.user.id}`);
|
||||
await saveUserEmailCredentials(session.user.id, userEmail, credentials);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user