From 6877db3227de21de26236685d23c5fc736876943 Mon Sep 17 00:00:00 2001 From: Tetardtek Date: Sun, 15 Mar 2026 01:57:41 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20login=20=E2=80=94=20setUser=20apr=C3=A8s?= =?UTF-8?q?=20auth=20pour=20maj=20header=20imm=C3=A9diate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/LoginPage.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/LoginPage.tsx b/frontend/src/pages/LoginPage.tsx index c83a234..25cdcf5 100644 --- a/frontend/src/pages/LoginPage.tsx +++ b/frontend/src/pages/LoginPage.tsx @@ -1,6 +1,7 @@ import { useState } from 'react'; import { Link, useNavigate, useLocation } from 'react-router-dom'; import { apiFetch } from '../lib/api'; +import { useAuthContext, type User } from '../context/AuthContext'; const PROVIDERS = [ { id: 'discord', label: 'Discord' }, @@ -12,6 +13,7 @@ const PROVIDERS = [ export default function LoginPage() { const navigate = useNavigate(); const location = useLocation(); + const { setUser } = useAuthContext(); const from = (location.state as { from?: Location })?.from?.pathname ?? '/'; const base = import.meta.env.VITE_SUPEROAUTH_URL; const redirectUrl = encodeURIComponent(window.location.origin + '/callback'); @@ -27,10 +29,11 @@ export default function LoginPage() { setLoading(true); setError(null); try { - await apiFetch('/auth/login', { + const res = await apiFetch<{ success: boolean; data: { user: User } }>('/auth/login', { method: 'POST', body: JSON.stringify({ email, password }), }); + setUser(res.data.user); navigate(from, { replace: true }); } catch { setError('Email ou mot de passe incorrect.');