felsey
09/17/2022, 8:29 AMerror: {"code": "42501", "details": null, "hint": null, "message": "new row violates row-level security policy for table \"lists\""}
This isn't making much sense to me because there is definitely a session for the user and I'm even passing in the user.id from the session into the user_id field in the table.
const handleCreateList = async () => {
try {
setIsLoading(true);
const { data, error } = await supabase
.from("lists")
.insert([
{
user_id: user.id,
name: listName,
google_place_id: selectedPlace.placeId,
google_place_name: selectedPlace.description,
google_place_types: JSON.stringify(selectedPlace.types),
},
])
.select();
if (error) {
throw error;
}
console.log(data[0].id);
navigation.navigate("ListOverview", { listId: data[0].id });
} catch (error) {
console.log("error: ", error);
} finally {
setIsLoading(false);
}
};
Any ideas what the issue could be?
I run into a similar row level security issue when trying to read data using select
with a logged in user.Nin
09/17/2022, 9:42 AMconst { data, error } = await supabase.auth.admin.getUserById(1)
It already seemed silly to me but.. how can we extract the uuid from the token with getServerSideProps (cookie)?
https://supabase.com/docs/reference/javascript/next/auth-admin-getuserbyid#fetch-the-user-object-using-the-access_token-jwtYashin
09/17/2022, 10:28 AMsupabase login
but I do not know how that would work on self-hosted.Math
09/17/2022, 10:31 AMaddresses
table. Here is my code:
JAVASCRIPT
const address_id = '322d4783-2692-4b63-a57e-a87ca248feb4';
console.log('address_id:', address_id);
const { data: address, error } = await supabase.from('addresses').update({ is_active: false }).eq('address_id', address_id);
if (address) return { status: 204 };
console.log('error:', error);
return { status: 400 };
for what I'm getting a empty array as a response:
address_id: 322d4783-2692-4b63-a57e-a87ca248feb4
error: []
seeing this: https://github.com/supabase/postgrest-js/issues/202,
I've verified twice the address_id
exists in my table, it works well when getting or inserting the data.
You'll find below my RLS policy for update (same as insert and select)
Would anyone know anything about it?
Can bring further information if you need it!jaf
09/17/2022, 1:19 PMclaims_admin
claim change claims. Now what I want to do is also let my service role update claims. Currently the function looks like this:
plpgsql
BEGIN
IF NOT is_claims_admin() THEN
RETURN 'error: access denied';
ELSE
update auth.users set raw_app_meta_data =
raw_app_meta_data ||
json_build_object(claim, value)::jsonb where id = uid;
return 'OK';
END IF;
END;
I want something like this but I don't know how to achieve it:
plpgsql
BEGIN
IF NOT is_claims_admin() OR **SERVICE_ROLE** THEN
RETURN 'error: access denied';
ELSE
update auth.users set raw_app_meta_data =
raw_app_meta_data ||
json_build_object(claim, value)::jsonb where id = uid;
return 'OK';
END IF;
END;
Sorry for tagging you @burggraf but you seem to be the maintainer of that package.tonyhart
09/17/2022, 2:55 PMhack1nt0sh
09/17/2022, 3:53 PMrlee128
09/17/2022, 3:55 PMNanoBit
09/17/2022, 3:57 PMsupa-audit
package, but I'm also curious about the widely used pgAudit
.
I noticed that supa-audit
supports a lot of OP/sec which works for me (small # users), but I would like to know other's opinion on the matter as well.
As I understand, log in pro plan lasts only 7 days so pgAudit
might not be long-termXki
09/17/2022, 4:29 PM.select()
request but my list is only 1000 rows, can i change this limit?Mechse
09/17/2022, 5:15 PMTypeError: Class extends value undefined is not a constructor or null
at file:///src/main.ts:40003:33
I tracked it down to using this in my edge function:
ts
const decoder = new TextDecoder();
The script works when testing outside the supabase ecosystem.
Had anyone a similar error?
Thank you so much in advance.
- Maxjdgamble555
09/17/2022, 5:58 PMphotos
such that:
- User's can only access one file: photo-images/${uid}.jpg
with CRUD operations.
I tried watching this:
Here is what I have, and it won't save:
typescript
bucket_id = 'photos' and (storage.foldername(name))[1] = 'profile_photos' and (storage.filename(name))[1] = (auth.uid()::text).jpg
JJesuscc9
09/17/2022, 6:57 PMven
09/17/2022, 7:18 PMGabriel Feitosa
09/17/2022, 7:42 PMlewisd
09/17/2022, 8:07 PMcreate function increment_kudos (giver_id uuid, receiver_id uuid, amount int)
returns void as
$$
update "userKudos"
set kudos = kudos + amount
where "giverId" = giver_id AND "receiverId" = receiver_id
$$
language sql volatile;
Problem is, the row needs to exist first if it is able to increment it.
Im quite new so im unsure of syntax regarding how to add this logic in sql
. Does anyone have any tips?turtlebasket
09/17/2022, 11:26 PMAmusedGrape
09/17/2022, 11:49 PMduplicate key value violates unique constraint "integration_data_pkey"
.
I've made no code or database changes, should I contact support about this?jdgamble555
09/18/2022, 2:04 AM(role() = 'authenticated'::text) AND (authorId.id = uuid())
Here authorId
is a FK to profiles.id
. I simply want to make sure a user can't insert a post where the author is someone else.
I get column "authorId" does not exist when trying to create the policy, but it does exist. It is an fk field.
JZetiMente
09/18/2022, 2:14 AMKickSquare
09/18/2022, 2:21 AMMrGandalfAndhi
09/18/2022, 3:11 AMak4zh
09/18/2022, 4:17 AMKickSquare
09/18/2022, 4:17 AMtherealphongtom
09/18/2022, 5:15 AMmessages
- id int8
- body varchar(255)
- user_id uid
my usecase is that i want to retrieve messages within users ( when signup it will create new record on users table ) but it doesn't work
supabase.from('messages').select("id, body, users (email)")
I searched google and found a solution that because default user table is private, so we need to create another table (account) to store users and create a trigger for DB, everytime when signup then insert record to account tableCory
09/18/2022, 5:27 AMthestepafter
09/18/2022, 6:32 AM{"message":"permission denied for schema private","code":"42501","details":null,"hint":null}%
What is the best approach for opening up security on these functions? Do I need to setup RLS on the tables in the private schema?jxyz
09/18/2022, 8:16 AMStarbyte
09/18/2022, 11:26 AMFailed to delete user: failed to delete user: update or delete on table "users" violates foreign key constraint "profiles_id_fkey" on table "profiles"
Xki
09/18/2022, 1:14 PM