From 343f4e4f268369d486081f340446da8041ac13bc Mon Sep 17 00:00:00 2001 From: Sonia Appasamy Date: Tue, 12 Dec 2023 13:35:49 -0500 Subject: [PATCH] client/web: refresh auth after syno login Makes sure we refresh auth state after synology auth has run. Updates #10261 Signed-off-by: Sonia Appasamy --- client/web/src/hooks/auth.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/web/src/hooks/auth.ts b/client/web/src/hooks/auth.ts index ba8c285d3..a79171c2e 100644 --- a/client/web/src/hooks/auth.ts +++ b/client/web/src/hooks/auth.ts @@ -25,6 +25,7 @@ export type AuthResponse = { export default function useAuth() { const [data, setData] = useState() const [loading, setLoading] = useState(true) + const [ranSynoAuth, setRanSynoAuth] = useState(false) const loadAuth = useCallback(() => { setLoading(true) @@ -37,6 +38,7 @@ export default function useAuth() { .then((r) => r.json()) .then((a) => { setSynoToken(a.SynoToken) + setRanSynoAuth(true) setLoading(false) }) break @@ -79,6 +81,10 @@ export default function useAuth() { // eslint-disable-next-line react-hooks/exhaustive-deps }, []) + useEffect(() => { + loadAuth() // Refresh auth state after syno auth runs + }, [loadAuth, ranSynoAuth]) + return { data, loading,