diff --git a/frontend/src/app/login/page.tsx b/frontend/src/app/login/page.tsx
index 3bafc83..da5a587 100644
--- a/frontend/src/app/login/page.tsx
+++ b/frontend/src/app/login/page.tsx
@@ -65,13 +65,9 @@ export default function LoginPage() {
setLoading(true);
try {
- // Login sem passar role, o backend decide
- console.log('🚀 [LOGIN FRONT] Tentando login com:', data.email);
const user = await login(data.email, data.password);
- console.log('✅ [LOGIN FRONT] Sucesso:', user);
if (user) {
- // Se "lembrar de mim" estiver marcado, salvar no localStorage
if (data.rememberMe) {
localStorage.setItem("rememberedEmail", data.email);
}
@@ -81,9 +77,6 @@ export default function LoginPage() {
setError(t("auth.login.errors.invalidCredentials"));
}
} catch (err: any) {
- console.error('🔥 [LOGIN FRONT] Erro no login:', err);
- console.error('🔥 [LOGIN FRONT] Detalhes:', err.response?.data || err.message);
-
const errorMessage = err.message;
if (errorMessage === "AUTH_INVALID_CREDENTIALS") {
setError(t("auth.login.errors.invalidCredentials"));
@@ -103,7 +96,6 @@ export default function LoginPage() {
return (
- {/* Left Side - Branding */}
- {/* Right Side - Login Form */}
({
export function AuthProvider({ children }: { children: React.ReactNode }) {
const [user, setUser] = useState
(null);
const [loading, setLoading] = useState(true);
+ const pathname = usePathname();
const checkSession = async () => {
try {
@@ -27,6 +29,16 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
setUser(stored);
}
+ const isAuthPage =
+ pathname === "/login" ||
+ pathname === "/register" ||
+ pathname === "/forgot-password";
+
+ if (!stored && isAuthPage) {
+ setUser(null);
+ return;
+ }
+
// Then verify with backend (httpOnly cookie)
const refreshedUser = await refreshSession();
if (refreshedUser) {
@@ -46,7 +58,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
useEffect(() => {
checkSession();
- }, []);
+ }, [pathname]);
return (
diff --git a/frontend/src/contexts/notification-context.tsx b/frontend/src/contexts/notification-context.tsx
index 6f59f31..fe62e92 100644
--- a/frontend/src/contexts/notification-context.tsx
+++ b/frontend/src/contexts/notification-context.tsx
@@ -4,7 +4,7 @@ import React, { createContext, useContext, useState, useCallback, useEffect } fr
import { toast } from "sonner";
import type { Notification } from "@/lib/types";
import { notificationsApi } from "@/lib/api";
-import { getCurrentUser } from "@/lib/auth";
+import { useAuth } from "@/contexts/AuthContext";
interface NotificationContextType {
notifications: Notification[];
@@ -28,12 +28,16 @@ export function NotificationProvider({
children: React.ReactNode;
}) {
const [notifications, setNotifications] = useState([]);
+ const { user, loading } = useAuth();
useEffect(() => {
const loadNotifications = async () => {
- // Only load notifications if user is authenticated
- const user = getCurrentUser();
+ if (loading) {
+ return;
+ }
+
if (!user) {
+ setNotifications([]);
return;
}
@@ -53,7 +57,7 @@ export function NotificationProvider({
}
};
loadNotifications();
- }, []);
+ }, [loading, user]);
const addNotification = useCallback(
(notification: Omit) => {
diff --git a/frontend/src/lib/config.ts b/frontend/src/lib/config.ts
index aa7a45b..c16fa69 100644
--- a/frontend/src/lib/config.ts
+++ b/frontend/src/lib/config.ts
@@ -57,7 +57,9 @@ export async function initConfig(): Promise {
const response = await fetch('/api/config');
if (response.ok) {
cachedConfig = await response.json();
- console.log('[Config] Loaded runtime config:', cachedConfig);
+ if (process.env.NODE_ENV === "development") {
+ console.log('[Config] Loaded runtime config:', cachedConfig);
+ }
} else {
console.warn('[Config] Failed to fetch config, using defaults');
cachedConfig = defaultConfig;