mirror of
https://github.com/docmost/docmost.git
synced 2026-09-11 07:56:54 +08:00
15 lines
517 B
TypeScript
15 lines
517 B
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import { getMyInfo } from "@/features/user/services/user-service";
|
|
import { ICurrentUser } from "@/features/user/types/user.types";
|
|
|
|
/** Probes login state from public surfaces; the /docs 401 exemption keeps anonymous visitors off the login redirect. */
|
|
export function useAuthenticatedUser(enabled = true) {
|
|
return useQuery<ICurrentUser>({
|
|
queryKey: ["currentUser"],
|
|
queryFn: getMyInfo,
|
|
retry: false,
|
|
staleTime: 5 * 60 * 1000,
|
|
enabled,
|
|
});
|
|
}
|