mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-15 11:32:09 +03:00
ensure anonymous user always returns all cameras
This commit is contained in:
parent
812a46d688
commit
0561a78bc9
@ -1,7 +1,22 @@
|
||||
import { useContext } from "react";
|
||||
import { AuthContext } from "@/context/auth-context";
|
||||
import useSWR from "swr";
|
||||
import { FrigateConfig } from "@/types/frigateConfig";
|
||||
|
||||
export function useAllowedCameras() {
|
||||
const { auth } = useContext(AuthContext);
|
||||
return auth.allowedCameras;
|
||||
const { data: config } = useSWR<FrigateConfig>("config", {
|
||||
revalidateOnFocus: false,
|
||||
});
|
||||
|
||||
if (
|
||||
auth.user?.role === "viewer" ||
|
||||
auth.user?.role === "admin" ||
|
||||
!auth.isAuthenticated // anonymous port 5000
|
||||
) {
|
||||
// return all cameras
|
||||
return config?.cameras ? Object.keys(config.cameras) : [];
|
||||
}
|
||||
|
||||
return auth.allowedCameras || [];
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user