mail page imap connection mime 5 bis rest 16 login page 18
This commit is contained in:
parent
35f726761b
commit
925e321759
@ -56,22 +56,31 @@ interface ImapConfig {
|
||||
function getStoredCredentials(): StoredCredentials | null {
|
||||
const cookieStore = cookies();
|
||||
|
||||
const email = cookieStore.get('imap_email')?.value;
|
||||
const password = cookieStore.get('imap_password')?.value;
|
||||
const host = cookieStore.get('imap_host')?.value;
|
||||
const port = cookieStore.get('imap_port')?.value;
|
||||
const credentialsCookie = cookieStore.get('imap_credentials');
|
||||
console.log('Retrieved credentials cookie:', credentialsCookie ? 'Found' : 'Not found');
|
||||
|
||||
if (!email || !password || !host || !port) {
|
||||
console.log('Missing credentials in cookies');
|
||||
if (!credentialsCookie?.value) {
|
||||
console.log('No credentials cookie found');
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
email,
|
||||
password,
|
||||
host,
|
||||
port: parseInt(port)
|
||||
};
|
||||
try {
|
||||
const credentials = JSON.parse(credentialsCookie.value);
|
||||
console.log('Parsed credentials:', {
|
||||
...credentials,
|
||||
password: '***'
|
||||
});
|
||||
|
||||
return {
|
||||
email: credentials.email,
|
||||
password: credentials.password,
|
||||
host: credentials.host,
|
||||
port: credentials.port
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error parsing credentials cookie:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function GET() {
|
||||
|
||||
@ -43,19 +43,29 @@ export default function LoginPage() {
|
||||
throw new Error(testData.error || 'Failed to connect to email server');
|
||||
}
|
||||
|
||||
// Store credentials in a cookie
|
||||
// Store all credentials in a single cookie
|
||||
const credentials = {
|
||||
email,
|
||||
password,
|
||||
host,
|
||||
port: parseInt(port),
|
||||
};
|
||||
|
||||
// Store each credential in a separate cookie
|
||||
setCookie('imap_email', email, { maxAge: 60 * 60 * 24 }); // 1 day
|
||||
setCookie('imap_password', password, { maxAge: 60 * 60 * 24 });
|
||||
setCookie('imap_host', host, { maxAge: 60 * 60 * 24 });
|
||||
setCookie('imap_port', port, { maxAge: 60 * 60 * 24 });
|
||||
|
||||
console.log('Storing credentials in cookie:', {
|
||||
...credentials,
|
||||
password: '***'
|
||||
});
|
||||
|
||||
// Store as a single cookie
|
||||
setCookie('imap_credentials', JSON.stringify(credentials), {
|
||||
maxAge: 60 * 60 * 24, // 1 day
|
||||
path: '/',
|
||||
sameSite: 'lax'
|
||||
});
|
||||
|
||||
// Verify cookie was set
|
||||
const stored = document.cookie.split(';').find(c => c.trim().startsWith('imap_credentials='));
|
||||
console.log('Cookie verification:', stored ? 'Cookie found' : 'Cookie not found');
|
||||
|
||||
// Redirect to mail page
|
||||
router.push('/mail');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user