From b6bbea61a164affd2f46b48a1a67daaa4b477e11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Wed, 22 Jul 2026 11:17:51 +0300 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=94=90=20remove=20setUser,=20?= =?UTF-8?q?use=20refresh()=20for=20login=20-=20remove=20setUser=20from=20a?= =?UTF-8?q?uth=20context;=20login=20uses=20refresh()=20(GET=20/me)=20-=20e?= =?UTF-8?q?liminates=20two=20paths=20for=20user=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/login-page.tsx | 4 ++-- src/stores/auth-context.tsx | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/pages/login-page.tsx b/src/pages/login-page.tsx index 6be5657..aa0c521 100644 --- a/src/pages/login-page.tsx +++ b/src/pages/login-page.tsx @@ -43,8 +43,8 @@ function LoginForm() { setError(""); setPending(true); try { - const user = await postLogin({ username: u, password: p }); - auth.setUser(user); + await postLogin({ username: u, password: p }); + await auth.refresh(); void navigate({ to: "/" }); } catch (err) { setError(formatApiError(err)); diff --git a/src/stores/auth-context.tsx b/src/stores/auth-context.tsx index 0324958..b123203 100644 --- a/src/stores/auth-context.tsx +++ b/src/stores/auth-context.tsx @@ -16,7 +16,6 @@ import { usePreferences } from "@/stores/preferences-context"; type AuthContextValue = { user: Accessor; loading: Accessor; - setUser: (user: User | null) => void; refresh: () => Promise; logout: () => Promise; }; @@ -41,8 +40,6 @@ export function AuthProvider(props: ParentProps) { return me(); }; - const setUser = (u: User | null) => setOverride(u); - createEffect(() => { const u = user(); if (u) prefs.hydratePreferences(u); @@ -65,7 +62,6 @@ export function AuthProvider(props: ParentProps) { const value: AuthContextValue = { user, loading: () => me.loading && override() === undefined, - setUser, refresh, logout, };