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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user