feat: Enhance JWT authentication error logging, gate notification fetching by user status, and enable Rust debug logging in Docker Compose.
This commit is contained in:
@@ -23,6 +23,7 @@ services:
|
|||||||
DATABASE_URL: postgresql://user:password@db:5432/openccb_cms
|
DATABASE_URL: postgresql://user:password@db:5432/openccb_cms
|
||||||
JWT_SECRET: ${JWT_SECRET:-openccb_secret_key_2025_production}
|
JWT_SECRET: ${JWT_SECRET:-openccb_secret_key_2025_production}
|
||||||
NEXT_PUBLIC_CMS_API_URL: ${NEXT_PUBLIC_CMS_API_URL:-http://localhost:3001}
|
NEXT_PUBLIC_CMS_API_URL: ${NEXT_PUBLIC_CMS_API_URL:-http://localhost:3001}
|
||||||
|
RUST_LOG: debug
|
||||||
LMS_INTERNAL_URL: http://experience:3002
|
LMS_INTERNAL_URL: http://experience:3002
|
||||||
volumes:
|
volumes:
|
||||||
- uploads_data:/app/uploads
|
- uploads_data:/app/uploads
|
||||||
@@ -45,6 +46,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
DATABASE_URL: postgresql://user:password@db:5432/openccb_lms
|
DATABASE_URL: postgresql://user:password@db:5432/openccb_lms
|
||||||
JWT_SECRET: ${JWT_SECRET:-openccb_secret_key_2025_production}
|
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_LMS_API_URL: ${NEXT_PUBLIC_LMS_API_URL:-http://localhost:3002}
|
||||||
NEXT_PUBLIC_CMS_API_URL: ${NEXT_PUBLIC_CMS_API_URL:-http://localhost:3001}
|
NEXT_PUBLIC_CMS_API_URL: ${NEXT_PUBLIC_CMS_API_URL:-http://localhost:3001}
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Invalid credentials
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
use axum::{
|
use axum::{
|
||||||
extract::{FromRequestParts, Request},
|
extract::{FromRequestParts, Request},
|
||||||
http::{request::Parts, StatusCode},
|
http::{StatusCode, request::Parts},
|
||||||
middleware::Next,
|
middleware::Next,
|
||||||
response::Response,
|
response::Response,
|
||||||
};
|
};
|
||||||
use jsonwebtoken::{decode, DecodingKey, Validation};
|
use jsonwebtoken::{DecodingKey, Validation, decode};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::auth::Claims;
|
use crate::auth::Claims;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { lmsApi, Notification } from "@/lib/api";
|
import { lmsApi, Notification } from "@/lib/api";
|
||||||
|
import { useAuth } from "@/context/AuthContext";
|
||||||
import { Bell, X, Calendar, Info, AlertTriangle, CheckCircle2 } from "lucide-react";
|
import { Bell, X, Calendar, Info, AlertTriangle, CheckCircle2 } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
@@ -10,7 +11,10 @@ export default function NotificationCenter() {
|
|||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const { user } = useAuth();
|
||||||
|
|
||||||
const fetchNotifications = async () => {
|
const fetchNotifications = async () => {
|
||||||
|
if (!user) return;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const data = await lmsApi.getNotifications();
|
const data = await lmsApi.getNotifications();
|
||||||
@@ -23,11 +27,13 @@ export default function NotificationCenter() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchNotifications();
|
if (user) {
|
||||||
// Poll every 5 minutes
|
fetchNotifications();
|
||||||
const interval = setInterval(fetchNotifications, 300000);
|
// Poll every 5 minutes
|
||||||
return () => clearInterval(interval);
|
const interval = setInterval(fetchNotifications, 300000);
|
||||||
}, []);
|
return () => clearInterval(interval);
|
||||||
|
}
|
||||||
|
}, [user]);
|
||||||
|
|
||||||
const markAsRead = async (id: string) => {
|
const markAsRead = async (id: string) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user