mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-08-11 13:48:37 +02:00
Merge ae9dece103
into 901218cdb2
This commit is contained in:
commit
966facb04f
@ -1,12 +1,12 @@
|
|||||||
// Authentication utility for cookie-based JWT
|
// Authentication utility for cookie-based JWT
|
||||||
window.JWTManager = {
|
window.JWTManager = {
|
||||||
|
|
||||||
// Logout - clear cookies and redirect to login
|
// Logout - clear cookies and redirect to login
|
||||||
logout: function() {
|
logout: function() {
|
||||||
|
|
||||||
// Clear JWT cookie manually (fallback)
|
// Clear JWT cookie manually (fallback)
|
||||||
document.cookie = 'stirling_jwt=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT; SameSite=None; Secure';
|
document.cookie = 'stirling_jwt=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT; SameSite=None; Secure';
|
||||||
|
|
||||||
// Perform logout request to clear server-side session
|
// Perform logout request to clear server-side session
|
||||||
fetch('/logout', {
|
fetch('/logout', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -55,14 +55,13 @@ window.fetchWithCsrf = async function(url, options = {}) {
|
|||||||
|
|
||||||
// Make the request
|
// Make the request
|
||||||
const response = await fetch(url, fetchOptions);
|
const response = await fetch(url, fetchOptions);
|
||||||
|
|
||||||
// Handle 401 responses (unauthorized)
|
// Handle 401 responses (unauthorized)
|
||||||
if (response.status === 401) {
|
if (response.status === 401) {
|
||||||
console.warn('Authentication failed, redirecting to login');
|
console.warn('Authentication failed, redirecting to login');
|
||||||
window.JWTManager.logout();
|
window.JWTManager.logout();
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
function initializeJWT() {
|
function initializeJWT() {
|
||||||
// Clean up any JWT tokens from URL (OAuth flow)
|
// Clean up any JWT tokens from URL (OAuth flow)
|
||||||
cleanupTokenFromUrl();
|
cleanupTokenFromUrl();
|
||||||
|
|
||||||
// Authentication is handled server-side
|
// Authentication is handled server-side
|
||||||
// If user is not authenticated, server will redirect to login
|
// If user is not authenticated, server will redirect to login
|
||||||
console.log('JWT initialization complete - authentication handled server-side');
|
console.log('JWT initialization complete - authentication handled server-side');
|
||||||
@ -41,4 +41,4 @@
|
|||||||
} else {
|
} else {
|
||||||
initializeJWT();
|
initializeJWT();
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user