fix(ui): update memory user when autoLogin enabled (#14018)

Fixes https://github.com/payloadcms/payload/issues/14005

When `autoLogin` is enabled, the Auth Provider's user in memory becomes
stale. This change ensures the user in memory stays up to date if
`autoLogin && !autoLogin.prefillOnly` is set.
This commit is contained in:
Jarrod Flesch
2025-10-07 13:51:43 -04:00
committed by GitHub
parent 7e128804e7
commit c2fa6299ee

View File

@@ -59,6 +59,7 @@ export function AuthProvider({
const {
admin: {
autoLogin,
autoRefresh,
routes: { inactivity: logoutInactivityRoute },
user: userSlug,
@@ -303,6 +304,12 @@ export function AuthProvider({
void fetchUserOnMount()
}, [])
useEffect(() => {
if (!user && autoLogin && !autoLogin.prefillOnly) {
void fetchFullUserEvent()
}
}, [user, autoLogin])
useEffect(
() => () => {
// remove all timeouts on unmount