CREATE POLICY "User can see their own profile only"
ON public.user
FOR SELECT
TO authenticated
USING ((SELECT auth.uid()) = id);
CREATE POLICY "Users can update their own profile"
ON public.user
FOR UPDATE
TO authenticated -- the Postgres Role
USING ((SELECT auth.uid()) = id) -- checks if the existing row complies with the policy expression
WITH CHECK ((SELECT auth.uid()) = id); -- checks if the new row complies with the policy expression
CREATE POLICY "User can see their own profile only"
ON public.user
FOR SELECT
TO authenticated
USING ((SELECT auth.uid()) = id);
CREATE POLICY "Users can update their own profile"
ON public.user
FOR UPDATE
TO authenticated -- the Postgres Role
USING ((SELECT auth.uid()) = id) -- checks if the existing row complies with the policy expression
WITH CHECK ((SELECT auth.uid()) = id); -- checks if the new row complies with the policy expression