mail page imap connection mime 5 bis rest 16 login page 15
This commit is contained in:
parent
3ce72c1b42
commit
f04e826f41
@ -54,30 +54,21 @@ interface ImapConfig {
|
||||
|
||||
function getStoredCredentials(): StoredCredentials | null {
|
||||
if (typeof window === 'undefined') {
|
||||
// Server-side
|
||||
const email = process.env.IMAP_USER;
|
||||
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
|
||||
};
|
||||
// Server-side - we should never get here in a client-side request
|
||||
return null;
|
||||
}
|
||||
|
||||
// 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() {
|
||||
|
||||
@ -25,7 +25,8 @@ export async function POST(request: Request) {
|
||||
|
||||
console.log('Testing IMAP connection with config:', {
|
||||
...imapConfig,
|
||||
password: '***'
|
||||
password: '***',
|
||||
email
|
||||
});
|
||||
|
||||
const imap = new Imap(imapConfig);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user