snassr
03/07/2022, 8:03 PMjoesaunderson
03/07/2022, 8:20 PM@supabase/supabase-auth-helpers
I have a profiles
table in the public
schema that is automatically created (via a trigger/function) when a user signs up (via email or a provider), I have a column on this table called role
which can be user
or admin
for now, depending on the signup flow.
I am struggling to set this role field when using the Auth
component in the helpers / when using third party providers.
With the email/password signup JS library it's possible to do:
supabase.auth.signUp({...}, {data: {role: 'admin'}})
which I can then access in my trigger/function to set the role on the profiles
table.
However, I am struggling to do similar (doesn't seem to exist) when signing in (or up) with a provider / when using the Auth
component.
Forgive me if I am missing something obvious here, but I would be grateful to see how others are doing similar. Thanks in advance.silentworks
03/07/2022, 11:52 PMsilentworks
03/07/2022, 11:57 PMScott P
03/08/2022, 1:02 AMowonwo
03/08/2022, 1:03 AMowonwo
03/08/2022, 1:03 AMLeoSonnekus
03/08/2022, 2:04 AMstnmonroe
03/08/2022, 2:30 AMnotes
and tags
, and a join table note_tags
, if I wanted to create a tag
and a relationship to a note
in a single transaction, what's the best approach, if possible?DavidBae
03/08/2022, 2:35 AMmcamendoza1
03/08/2022, 6:16 AMv.naeimabadi
03/08/2022, 7:16 AMconst mySubscription = supabase
.from('*')
.on('*', payload => {
console.log('Change received!', payload)
}).subscribe((status, e) => console.log(status, e))
for android 7.0 i got *SUBSCRIBED *
but in and android 10 i am getting two status:
status= RETRYING_AFTER_TIMEOUT ,error= undefined
and then
*status= SUBSCRIPTION_ERROR ,error= undefined *
any idea what's going on? @Userak4zh
03/08/2022, 7:38 AMsql
CREATE TABLE IF NOT EXISTS public.orgs
(
id uuid NOT NULL DEFAULT uuid_generate_v4(),
created_at timestamp with time zone DEFAULT now(),
name text COLLATE pg_catalog."default" NOT NULL,
owner_id uuid NOT NULL DEFAULT auth.uid(),
description text COLLATE pg_catalog."default",
CONSTRAINT orgs_pkey PRIMARY KEY (id),
CONSTRAINT orgs_owner_id_fkey FOREIGN KEY (owner_id)
REFERENCES auth.users (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
CREATE TABLE IF NOT EXISTS public.org_members
(
id bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 ),
created_at timestamp with time zone NOT NULL DEFAULT now(),
org_id uuid NOT NULL,
user_id uuid NOT NULL,
"select" boolean NOT NULL DEFAULT true,
insert boolean NOT NULL DEFAULT true,
update boolean NOT NULL DEFAULT true,
delete boolean NOT NULL DEFAULT false,
CONSTRAINT org_members_pkey PRIMARY KEY (id),
CONSTRAINT org_members_org_id_fkey FOREIGN KEY (org_id)
REFERENCES public.orgs (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT org_members_user_id_fkey FOREIGN KEY (user_id)
REFERENCES auth.users (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
RLS on public.orgs
- SELECT by owner and org members achieved with:
sql
CREATE POLICY "Enable access to org owner and org members"
ON public.orgs
AS PERMISSIVE
FOR SELECT
TO public
USING (
(auth.uid() = owner_id)
OR
(
id IN ( SELECT org_members.org_id FROM public.org_members WHERE user_id = auth.uid() AND org_members."select" = true)
)
);
- INSERT, UPDATE and DELETE by owner only achieved with auth.uid() = owner_id
RLS on public.org_members
- SELECT, INSERT, UPDATE and DELETE by org owner only
When I creaate policy here it results in recurssion.
What would be the appropriate solution?ak4zh
03/08/2022, 11:03 AMsilentworks
03/08/2022, 12:37 PMApfelsaft
03/08/2022, 1:46 PManggoran
03/08/2022, 3:08 PMryfill
03/08/2022, 3:33 PMgaryaustin
03/08/2022, 4:36 PMbake
03/08/2022, 5:09 PMgaryaustin
03/08/2022, 5:23 PMryfill
03/08/2022, 8:42 PMdocker-compose
and dummy .env
file??brgrz
03/08/2022, 10:31 PMgaryaustin
03/08/2022, 10:46 PMirrationaljared
03/08/2022, 11:02 PMMigration `20220308221326_init` failed to apply cleanly to the shadow database.
Error:
db error: ERROR: function auth.uid() does not exist
Here is the relevant part of the initial migration:
CREATE SCHEMA IF NOT EXISTS "auth";
[How can I check for auth.uid() here?]
CREATE SCHEMA IF NOT EXISTS "extensions";
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA extensions;
CREATE EXTENSION IF NOT EXISTS "moddatetime" SCHEMA extensions;
Any help would be greatly appreciatedelliott
03/09/2022, 2:09 AM.from('reviews')
.select('*, profile:user_id(*)')
which works fine. However, I want to also get a relation from the profile table, which has followers. Something like this:
.from('reviews')
.select('*, profile:user_id(*, follows:follower_id(*))')
Where follower_id is the ID that a "follow" object has which relates to the id of a "follow" to the "profile" table. I want to be able to use this "follows" object in the filtering of the query later.
Does this question make sense? Sorry my SQL skills are weak, still learning. I've read the docs through for what it's worth and couldn't figure this one out.. Thank you!garyaustin
03/09/2022, 2:28 AMPaul AKA TDI
03/09/2022, 4:49 AMPaul AKA TDI
03/09/2022, 1:31 PM