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 {
|
function getStoredCredentials(): StoredCredentials | null {
|
||||||
const cookieStore = cookies();
|
const cookieStore = cookies();
|
||||||
|
|
||||||
const email = cookieStore.get('imap_email')?.value;
|
const credentialsCookie = cookieStore.get('imap_credentials');
|
||||||
const password = cookieStore.get('imap_password')?.value;
|
console.log('Retrieved credentials cookie:', credentialsCookie ? 'Found' : 'Not found');
|
||||||
const host = cookieStore.get('imap_host')?.value;
|
|
||||||
const port = cookieStore.get('imap_port')?.value;
|
|
||||||
|
|
||||||
if (!email || !password || !host || !port) {
|
if (!credentialsCookie?.value) {
|
||||||
console.log('Missing credentials in cookies');
|
console.log('No credentials cookie found');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
try {
|
||||||
email,
|
const credentials = JSON.parse(credentialsCookie.value);
|
||||||
password,
|
console.log('Parsed credentials:', {
|
||||||
host,
|
...credentials,
|
||||||
port: parseInt(port)
|
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() {
|
export async function GET() {
|
||||||
|
|||||||
@ -43,7 +43,7 @@ export default function LoginPage() {
|
|||||||
throw new Error(testData.error || 'Failed to connect to email server');
|
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 = {
|
const credentials = {
|
||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
@ -51,11 +51,21 @@ export default function LoginPage() {
|
|||||||
port: parseInt(port),
|
port: parseInt(port),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Store each credential in a separate cookie
|
console.log('Storing credentials in cookie:', {
|
||||||
setCookie('imap_email', email, { maxAge: 60 * 60 * 24 }); // 1 day
|
...credentials,
|
||||||
setCookie('imap_password', password, { maxAge: 60 * 60 * 24 });
|
password: '***'
|
||||||
setCookie('imap_host', host, { maxAge: 60 * 60 * 24 });
|
});
|
||||||
setCookie('imap_port', port, { maxAge: 60 * 60 * 24 });
|
|
||||||
|
// 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
|
// Redirect to mail page
|
||||||
router.push('/mail');
|
router.push('/mail');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user