mail page imap connection mime 5 bis rest 16 login page 15

This commit is contained in:
alma 2025-04-16 00:20:55 +02:00
parent 3ce72c1b42
commit f04e826f41
2 changed files with 16 additions and 24 deletions

View File

@ -54,30 +54,21 @@ interface ImapConfig {
function getStoredCredentials(): StoredCredentials | null { function getStoredCredentials(): StoredCredentials | null {
if (typeof window === 'undefined') { if (typeof window === 'undefined') {
// Server-side // Server-side - we should never get here in a client-side request
const email = process.env.IMAP_USER; return null;
const password = process.env.IMAP_PASSWORD;
const host = process.env.IMAP_HOST;
const port = process.env.IMAP_PORT ? parseInt(process.env.IMAP_PORT) : 993;
if (!email || !password || !host) {
return null;
}
return { email, password, host, port };
} else {
// Client-side
const stored = localStorage.getItem('imapCredentials');
if (!stored) return null;
const credentials = JSON.parse(stored);
return {
email: credentials.email,
password: credentials.password,
host: credentials.host,
port: credentials.port
};
} }
// Client-side
const stored = localStorage.getItem('imapCredentials');
if (!stored) return null;
const credentials = JSON.parse(stored);
return {
email: credentials.email,
password: credentials.password,
host: credentials.host,
port: credentials.port
};
} }
export async function GET() { export async function GET() {

View File

@ -25,7 +25,8 @@ export async function POST(request: Request) {
console.log('Testing IMAP connection with config:', { console.log('Testing IMAP connection with config:', {
...imapConfig, ...imapConfig,
password: '***' password: '***',
email
}); });
const imap = new Imap(imapConfig); const imap = new Imap(imapConfig);