Skip to content

Commit

Permalink
Fixed race condition bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hkam0006 committed Oct 22, 2024
1 parent 6965adb commit 418cffa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions frontend/src/hooks/useAuthListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const useAuthListener = () => {
if (Boolean(storedUser) && event !== "SIGNED_OUT") {
return
}
dispatch(setLoading(true))
await dispatch(setLoading(true))
if ((event === 'SIGNED_IN' ) && session) {
const user = session.user;
// Example role-checking logic
Expand All @@ -62,9 +62,9 @@ const useAuthListener = () => {
...item,
company_id: companyIDData[0].company_id
}));
dispatch(setManager())
dispatch(setUser(data[0]))
dispatch(setLoading(false))
await dispatch(setManager())
await dispatch(setUser(data[0]))
await dispatch(setLoading(false))
}
});
}
Expand All @@ -77,9 +77,9 @@ const useAuthListener = () => {
}
})
} else if (event === 'SIGNED_OUT'){
dispatch(logout())
navigate("/Landing")
dispatch(setLoading(false))
await dispatch(logout())
await navigate("/Landing")
await dispatch(setLoading(false))
}
});

Expand Down

0 comments on commit 418cffa

Please sign in to comment.