Index: backend/controllers/apiController.js
===================================================================
--- backend/controllers/apiController.js	(revision d44298bcbe40fd15d76afbb70c5223744dd24715)
+++ backend/controllers/apiController.js	(revision baed897de4f10aee2b403d25d43e3d1fe0d1f17d)
@@ -84,5 +84,4 @@
         isModerator: studentInstance.isModerator || false,
         solvedDailyChallenge: studentInstance.solvedDailyChallenge || false,
-
       },
     });
@@ -124,4 +123,12 @@
         .json({ message: 'Email and password are required', success: false });
     }
+    const userData = await prisma.users.findUnique({
+      where: { email: email },
+    });
+    if (!userData) {
+      return res
+        .status(404)
+        .json({ message: 'User not found in database', success: false });
+    }
 
     const { data, error } = await supabase.auth.signInWithPassword({
@@ -148,13 +155,13 @@
 
       res.status(200).json({
-        message: 'Login successful',
+        message: 'User data retrieved',
         success: true,
         user: safeUserData,
       });
-    } catch (dbError) {
-      console.error('Database error:', dbError);
-      return res
+    } catch (error) {
+      console.error('Login error:', error);
+      res
         .status(500)
-        .json({ message: 'Database error', success: false });
+        .json({ message: 'An error occurred during login', success: false });
     }
   } catch (error) {
Index: backend/scripts/resetPostCounters.js
===================================================================
--- backend/scripts/resetPostCounters.js	(revision d44298bcbe40fd15d76afbb70c5223744dd24715)
+++ backend/scripts/resetPostCounters.js	(revision baed897de4f10aee2b403d25d43e3d1fe0d1f17d)
@@ -4,4 +4,7 @@
 async function resetPostCounters() {
   try {
+    console.log(
+      `[${new Date().toISOString()}] Attempting to reset post counters...`
+    );
     const result = await prisma.users.updateMany({
       data: {
@@ -9,21 +12,43 @@
       },
     });
+    console.log(
+      `[${new Date().toISOString()}] Successfully reset post counters for ${
+        result.count
+      } users.`
+    );
+    return result;
   } catch (error) {
-    console.error('Error resetting post counters:', error);
+    console.error(
+      `[${new Date().toISOString()}] Error resetting post counters:`,
+      error
+    );
   } finally {
     await prisma.$disconnect();
+    console.log(`[${new Date().toISOString()}] Database connection closed.`);
   }
 }
+
 const job = schedule.scheduleJob('0 0 * * *', function () {
   console.log(
-    `Running scheduled post counter reset at ${new Date().toISOString()}`
+    `[${new Date().toISOString()}] Running scheduled post counter reset at midnight.`
   );
   resetPostCounters();
 });
+
+console.log(`[${new Date().toISOString()}] Post counter reset script started.`);
+console.log(
+  `[${new Date().toISOString()}] Next scheduled run: ${job.nextInvocation()}`
+);
+
 process.on('SIGINT', function () {
   job.cancel();
-  console.log('Post counter reset scheduler stopped');
+  console.log(
+    `[${new Date().toISOString()}] Post counter reset scheduler stopped`
+  );
   process.exit(0);
 });
 
+console.log(
+  `[${new Date().toISOString()}] Running initial post counter reset...`
+);
 resetPostCounters();
Index: client/src/Dashboard/components/Navbar.jsx
===================================================================
--- client/src/Dashboard/components/Navbar.jsx	(revision d44298bcbe40fd15d76afbb70c5223744dd24715)
+++ client/src/Dashboard/components/Navbar.jsx	(revision baed897de4f10aee2b403d25d43e3d1fe0d1f17d)
@@ -114,5 +114,5 @@
           />
           <div
-            className="flex flex-col items-start"
+            className="flex flex-col items-start cursor-pointer"
             onClick={() => navigate('/dashboard/profile')}
           >
Index: client/src/Dashboard/components/Profile.jsx
===================================================================
--- client/src/Dashboard/components/Profile.jsx	(revision d44298bcbe40fd15d76afbb70c5223744dd24715)
+++ client/src/Dashboard/components/Profile.jsx	(revision baed897de4f10aee2b403d25d43e3d1fe0d1f17d)
@@ -1,17 +1,20 @@
 // Example for Profile.jsx
-import React from "react";
-import pp from "../../assets/images/pp.svg";
-import Navbar from "./Navbar";
-import RankBadge from "@/utils/RankBadge.jsx";
-
+import React from 'react';
+import pp from '../../assets/images/pp.svg';
+import Navbar from './Navbar';
+import RankBadge from '@/utils/RankBadge.jsx';
+import { useAuth } from '../../contexts/AuthContext.jsx';
+import { useNavigate } from 'react-router-dom';
 const Profile = () => {
-  const handleSignOut = () => {
-    localStorage.removeItem("user");
-    window.location.href = "/";
+  const { logout } = useAuth();
+  const navigate = useNavigate();
+  const handleSignOut = async () => {
+    await logout();
+    navigate('/');
   };
-  const user = JSON.parse(localStorage.getItem("user"));
-  console.log("User data:", user);
+  const user = JSON.parse(localStorage.getItem('user'));
+  console.log('User data:', user);
   if (!user) {
-    console.error("No user data found in localStorage.");
+    console.error('No user data found in localStorage.');
   }
   return (
Index: client/src/LogIn/LogIn.jsx
===================================================================
--- client/src/LogIn/LogIn.jsx	(revision d44298bcbe40fd15d76afbb70c5223744dd24715)
+++ client/src/LogIn/LogIn.jsx	(revision baed897de4f10aee2b403d25d43e3d1fe0d1f17d)
@@ -21,4 +21,13 @@
 
     try {
+      const { data: authData, error: authError } =
+        await supabase.auth.signInWithPassword({
+          email,
+          password,
+        });
+      if (authError) {
+        setError(authError.message);
+        return;
+      }
       const response = await fetch('/api/login', {
         method: 'POST',
@@ -33,8 +42,5 @@
       if (data.success) {
         localStorage.setItem('user', JSON.stringify(data.user));
-        await supabase.auth.signInWithPassword({
-          email,
-          password,
-        });
+
         navigate('/dashboard');
       } else {
Index: client/src/contexts/AuthContext.jsx
===================================================================
--- client/src/contexts/AuthContext.jsx	(revision d44298bcbe40fd15d76afbb70c5223744dd24715)
+++ client/src/contexts/AuthContext.jsx	(revision baed897de4f10aee2b403d25d43e3d1fe0d1f17d)
@@ -23,5 +23,5 @@
 
   // Inactivity duration in milliseconds (30 minutes)
-  const INACTIVITY_TIMEOUT = 30 * 60 * 1000;
+  const INACTIVITY_TIMEOUT = 5 * 60 * 1000;
 
   // Function to handle logout - use useCallback to prevent recreation on every render
@@ -65,5 +65,5 @@
     const handleActivity = () => {
       if (user) {
-        // Only reset if there's a user
+        localStorage.setItem('lastActivityTimestamp', Date.now().toString());
         resetInactivityTimer();
       }
@@ -137,4 +137,20 @@
     };
   }, []);
+  useEffect(() => {
+    const checkLastActivity = () => {
+      const lastActivity = localStorage.getItem('lastActivityTimestamp');
+      if (lastActivity && user) {
+        const inactiveTime = Date.now() - parseInt(lastActivity);
+        if (inactiveTime > INACTIVITY_TIMEOUT) {
+          console.log('Detected inactivity between sessions');
+          logout();
+        }
+      }
+    };
+
+    if (user) {
+      checkLastActivity();
+    }
+  }, [user, logout, INACTIVITY_TIMEOUT]);
 
   // Auth context value
Index: ecosystem.config.js
===================================================================
--- ecosystem.config.js	(revision d44298bcbe40fd15d76afbb70c5223744dd24715)
+++ ecosystem.config.js	(revision baed897de4f10aee2b403d25d43e3d1fe0d1f17d)
@@ -4,20 +4,16 @@
       name: 'daily-resets-job',
       script: './backend/scripts/dailyResets.js',
-      cron_restart: '0 7 * * *', // 5 AM UTC = 7 AM Macedonian Time
-      autorestart: false,
+      autorestart: true,
       watch: false,
       instances: 1,
       exec_mode: 'fork',
-      one_based_action: true,
     },
     {
       name: 'post-counter-reset',
-      script: './backend/scripts/resetPostCounters.js', // Adjust path if different
-      cron_restart: '0 0 * * *',
-      autorestart: false,
+      script: './backend/scripts/resetPostCounters.js',
+      autorestart: true,
       watch: false,
       instances: 1,
       exec_mode: 'fork',
-      one_based_action: true,
     },
   ],
