fix: harden machine session fallback and clean lint
This commit is contained in:
parent
2607ca5ce3
commit
846e575637
6 changed files with 60 additions and 32 deletions
|
|
@ -109,6 +109,11 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
|||
// carregar o contexto — se a API responder 200, assumimos que há sessão válida
|
||||
// do lado do servidor e populamos o contexto para o restante do app.
|
||||
useEffect(() => {
|
||||
if (isPending) {
|
||||
setMachineContextLoading(true)
|
||||
return
|
||||
}
|
||||
|
||||
const shouldFetch = Boolean(session?.user?.role === "machine") || !session?.user
|
||||
if (!shouldFetch) {
|
||||
setMachineContext(null)
|
||||
|
|
@ -215,7 +220,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
|||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [session?.user])
|
||||
}, [session?.user, isPending])
|
||||
|
||||
// Poll machine session periodically to reflect admin changes (e.g., deactivation)
|
||||
useEffect(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue