logout secure
This commit is contained in:
@@ -7,12 +7,12 @@ export async function POST() {
|
|||||||
|
|
||||||
// Clear the session cookie
|
// Clear the session cookie
|
||||||
response.cookies.set('user_session', '', {
|
response.cookies.set('user_session', '', {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
secure: process.env.NODE_ENV === 'production',
|
secure: false, // Set to false to allow HTTP (for Coolify deployment)
|
||||||
sameSite: 'lax',
|
sameSite: 'lax',
|
||||||
maxAge: 0, // Expire immediately
|
maxAge: 0, // Expire immediately
|
||||||
path: '/',
|
path: '/',
|
||||||
});
|
});
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,8 +87,10 @@ const Navbar = () => {
|
|||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
setUser(null);
|
setUser(null);
|
||||||
showSuccess("Berhasil!", "Anda telah keluar dari sistem");
|
showSuccess("Berhasil!", "Anda telah keluar dari sistem");
|
||||||
// Redirect to root page after successful logout
|
// Redirect to root page after successful logout - using window.location for hard redirect
|
||||||
router.push('/');
|
setTimeout(() => {
|
||||||
|
window.location.href = '/';
|
||||||
|
}, 500); // Small delay to show toast notification
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Logout error:', error);
|
console.error('Logout error:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user