From 6927ac2d230373be9ab3b1107924ae5745ab5dd4 Mon Sep 17 00:00:00 2001 From: Nurfog Date: Sun, 15 Feb 2026 15:10:42 -0300 Subject: [PATCH] feat: Enhance JWT authentication error logging, gate notification fetching by user status, and enable Rust debug logging in Docker Compose. --- docker-compose.yml | 2 ++ login.json | 1 + shared/common/src/middleware.rs | 4 ++-- token.txt | 0 .../src/components/NotificationCenter.tsx | 16 +++++++++++----- 5 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 login.json create mode 100644 token.txt diff --git a/docker-compose.yml b/docker-compose.yml index 97c98e0..b4209d1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,7 @@ services: DATABASE_URL: postgresql://user:password@db:5432/openccb_cms JWT_SECRET: ${JWT_SECRET:-openccb_secret_key_2025_production} NEXT_PUBLIC_CMS_API_URL: ${NEXT_PUBLIC_CMS_API_URL:-http://localhost:3001} + RUST_LOG: debug LMS_INTERNAL_URL: http://experience:3002 volumes: - uploads_data:/app/uploads @@ -45,6 +46,7 @@ services: environment: DATABASE_URL: postgresql://user:password@db:5432/openccb_lms JWT_SECRET: ${JWT_SECRET:-openccb_secret_key_2025_production} + RUST_LOG: debug NEXT_PUBLIC_LMS_API_URL: ${NEXT_PUBLIC_LMS_API_URL:-http://localhost:3002} NEXT_PUBLIC_CMS_API_URL: ${NEXT_PUBLIC_CMS_API_URL:-http://localhost:3001} env_file: .env diff --git a/login.json b/login.json new file mode 100644 index 0000000..ea0899c --- /dev/null +++ b/login.json @@ -0,0 +1 @@ +Invalid credentials \ No newline at end of file diff --git a/shared/common/src/middleware.rs b/shared/common/src/middleware.rs index 2e68c0f..5fa916f 100644 --- a/shared/common/src/middleware.rs +++ b/shared/common/src/middleware.rs @@ -1,10 +1,10 @@ use axum::{ extract::{FromRequestParts, Request}, - http::{request::Parts, StatusCode}, + http::{StatusCode, request::Parts}, middleware::Next, response::Response, }; -use jsonwebtoken::{decode, DecodingKey, Validation}; +use jsonwebtoken::{DecodingKey, Validation, decode}; use uuid::Uuid; use crate::auth::Claims; diff --git a/token.txt b/token.txt new file mode 100644 index 0000000..e69de29 diff --git a/web/experience/src/components/NotificationCenter.tsx b/web/experience/src/components/NotificationCenter.tsx index 0d0b8bc..ebbb49f 100644 --- a/web/experience/src/components/NotificationCenter.tsx +++ b/web/experience/src/components/NotificationCenter.tsx @@ -2,6 +2,7 @@ import { useState, useEffect } from "react"; import { lmsApi, Notification } from "@/lib/api"; +import { useAuth } from "@/context/AuthContext"; import { Bell, X, Calendar, Info, AlertTriangle, CheckCircle2 } from "lucide-react"; import Link from "next/link"; @@ -10,7 +11,10 @@ export default function NotificationCenter() { const [isOpen, setIsOpen] = useState(false); const [loading, setLoading] = useState(false); + const { user } = useAuth(); + const fetchNotifications = async () => { + if (!user) return; setLoading(true); try { const data = await lmsApi.getNotifications(); @@ -23,11 +27,13 @@ export default function NotificationCenter() { }; useEffect(() => { - fetchNotifications(); - // Poll every 5 minutes - const interval = setInterval(fetchNotifications, 300000); - return () => clearInterval(interval); - }, []); + if (user) { + fetchNotifications(); + // Poll every 5 minutes + const interval = setInterval(fetchNotifications, 300000); + return () => clearInterval(interval); + } + }, [user]); const markAsRead = async (id: string) => { try {