jkl
08/07/2021, 5:43 AMDarkyellow
08/07/2021, 5:55 AMSubh
08/07/2021, 6:51 AMquery {
post_by_pk(project_id: "some_uuid_for_post"){
ifLiked: likes(where: {
user_id: {
_eq: "i_logged_in_with_this_uuid"
}
}) {
id
}
likes(limit: 10) {
user {
name
id
}
}
total_like: likes_aggregate {
aggregate {
count
}
}
}
}
Waldemar
08/07/2021, 9:47 AMwhytry
08/07/2021, 12:45 PMsherlock
08/07/2021, 1:12 PMcarlomigueldy.eth
08/07/2021, 1:57 PMcarlomigueldy.eth
08/07/2021, 1:58 PMLink
08/07/2021, 3:06 PMLink
08/07/2021, 3:06 PMLink
08/07/2021, 3:08 PMHarryET
08/07/2021, 3:14 PMpublic, private & email
and you want private & email to only be allowed if authenticatedKosh
08/07/2021, 3:20 PMHarryET
08/07/2021, 3:22 PMKosh
08/07/2021, 3:25 PMHarryET
08/07/2021, 3:43 PMHarryET
08/07/2021, 3:43 PMsql
CREATE VIEW hidden_account_info as select email, employee_id, name from public.accounts;
CREATE POLICY "Hide protected account info from the public"
on hidden_account_info
for select
using (
id = auth.uid() OR -- ID Not found as not in the view
is_account_admin(
(SELECT * FROM public.accounts WHERE id = auth.uid())
)
);
HarryET
08/07/2021, 3:58 PMsql
CREATE OR REPLACE FUNCTION f_hidden_account_info(user_id uuid)
RETURNS boolean as $$
declare
account public.accounts := (SELECT * FROM public.accounts WHERE id = auth.uid());
begin
IF account.id = user_id OR is_account_admin(account) THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
end;
$$ stable language plpgsql security definer;
CREATE VIEW hidden_account_info as select email, employee_id, name from public.accounts;
CREATE POLICY "Hide protected account info from the public"
on hidden_account_info
for select
using (f_hidden_account_info(auth.uid()));
sumchans
08/07/2021, 4:20 PMIvanCodes
08/07/2021, 4:23 PMsumchans
08/07/2021, 4:24 PMIvanCodes
08/07/2021, 4:26 PMsumchans
08/07/2021, 4:30 PMjon.m
08/07/2021, 5:58 PMfunction MyApp({ Component, pageProps }) {
const [user, setUser] = useState(null);
useEffect(() => {
const { data: authListener } = supabase.auth.onAuthStateChange(async () =>
checkUser()
);
checkUser();
return () => {
authListener?.unsubscribe();
};
}, []);
async function checkUser() {
const user = supabase.auth.user();
console.log(user);
setUser(user);
}
return (
<Provider store={store}>
<Layout>
<Component {...pageProps} />
</Layout>
</Provider>
);
}
jon.m
08/07/2021, 5:58 PMTeesh3rt
08/07/2021, 6:06 PMHarryET
08/07/2021, 6:08 PMTeesh3rt
08/07/2021, 6:11 PMHarryET
08/07/2021, 7:04 PMjon.m
08/07/2021, 10:14 PM