|
|
@@ -2,6 +2,8 @@ const API_BASE_URL = '/api';
|
|
|
let currentUser = null;
|
|
|
let resetToken = null;
|
|
|
|
|
|
+checkForExpiredToken();
|
|
|
+
|
|
|
// Theme management
|
|
|
function initializeTheme() {
|
|
|
const savedTheme = localStorage.getItem('theme') || 'light';
|
|
|
@@ -471,6 +473,19 @@ function maskUserEmail(email) {
|
|
|
return `${first}${maskedPart}${last}@${domain}`;
|
|
|
}
|
|
|
|
|
|
+function checkForExpiredToken() {
|
|
|
+ const userDataString = localStorage.getItem("userData");
|
|
|
+
|
|
|
+ if (!userDataString) return true;
|
|
|
+
|
|
|
+ const userData = JSON.parse(userDataString);
|
|
|
+ const expirationDate = new Date(userData.expirationDate);
|
|
|
+
|
|
|
+ if (expirationDate < new Date()) {
|
|
|
+ logout();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function logout() {
|
|
|
localStorage.removeItem('authToken');
|
|
|
localStorage.removeItem('userData');
|