Ramdinpuia29
12/20/2022, 11:48 AMCREATE POLICY user_update_own_scores ON my_scores
FOR ALL
USING (auth.uid() = user_id);
into something like
CREATE POLICY user_update_own_scores ON my_scores
FOR ALL
USING (auth.uid() = user_id OR email='email@example.com');
Pum Pum
12/20/2022, 11:56 AMuserid
and inside that I was storing files. after that I made that bucket private and now I can't access the file using the CDN
what I want is to let the owner access their file and no one else how can I do that in a private bucket?SM0RT
12/20/2022, 12:04 PMsql
"id" (uuid, PK)
"username" (text)
"language_code" (char(2))
Imagine I have a database of cars with a table called "car", with the following columns
sql
"id" (uuid, PK, default: uuid_generate_v4()),
"user_id" (uuid, FK to the user this car belongs to, required, no default)
"brand_name" (varchar, required, no default)
"model_name" (text, required, no default)
"created_at" (timestampz, default: now())
"isDefaultEN" (bool, default: false)
"isDefaultDE" (bool, default: false)
To achieve this, I would create a trigger like so:
sql
-- inserts a row into public.car
create function public.handle_new_profile()
returns trigger
language plpgsql
security definer set search_path = public
as $$
begin
[FOLLOWING CODE GOES HERE]
end;
$$;
-- trigger the function every time a user is created
create trigger on_profile_created
after insert on public.profile
for each row execute procedure public.handle_new_profile();
simonbarker
12/20/2022, 12:13 PMimport { createServerSupabaseClient } from '@supabase/auth-helpers-nextjs'
Causes this message to appear in the terminal:
SyntaxError: Unexpected token 'export'
Without that import the endpoint is fine,
From my package.json:
"next": "12.0.7",
"@supabase/supabase-js": "^2.2.1",
"@supabase/auth-helpers-nextjs": "^0.5.2",
"@supabase/auth-helpers-react": "^0.3.1",
All the client side auth seems to be working fine (I had to upgrade @supabase/supabase-js
from 1.3.5 to 2.2.1)
Any ideas on how to fix this would be very appreciated.
Thankschinds
12/20/2022, 12:58 PMνλμ
12/20/2022, 1:56 PMGuy Rozen
12/20/2022, 2:03 PMzeedee
12/20/2022, 4:26 PMemail()
function for custom emails.
Thanks in advance.Creix
12/20/2022, 5:05 PMmrmikardo
12/20/2022, 5:09 PMbegin
insert into public.example_table (user_id, access_token_id)
values (new.user_id, new.id);
end;
The only issue is, new
doesn't contain a reference to user_id
. Is there a function or something I can use to grab a reference to the user attempting the insert?vipultanwar
12/20/2022, 5:31 PMnovon
12/20/2022, 6:06 PMhelp.company.com
to our assigned subdomain like company.ourapp.com
and still have Supabase Auth manage authentication on both?(FOX)
12/20/2022, 6:20 PMhqn
12/20/2022, 6:30 PMzeedee
12/20/2022, 6:48 PMjs
// functions/samsara_hooks/index.ts
import { serve } from "https://deno.land/std@0.131.0/http/server.ts"
console.log("Hello from Functions!")
serve(async (req) => {
const { name } = await req.json()
const data = {
message: `Hello ${name}!`,
}
return new Response(
JSON.stringify(data),
{ headers: { "Content-Type": "application/json" } },
)
})
Is there a chance that Supabase is blocking it?AliCodes!
12/20/2022, 8:30 PMNicoY
12/20/2022, 8:59 PMRon W
12/20/2022, 9:22 PM"Enable insert for authenticated users only"
using the available template. However, even after enabling this policy I can still insert to the table using the anon
role, without having to log in as a user with the authenticated
role. This is undesirable behaviour.
A screenshot of the policy window is attached. The only other policy enabled for the table is the Enable read access for all users
policy, which was also generated from the template without modification.zeedee
12/20/2022, 10:11 PMEmruur
12/20/2022, 10:25 PMzeedee
12/20/2022, 10:47 PMjs
serve(async (req: Request) => {
const secret = decode(Deno.env.get('SAMSARA_WEBHOOK_SECRET'))
console.log("secret: " + secret)
const request = await req.json()
if (true) {
return New Response({
status: 404
})
}
)
return new Response(
JSON.stringify(),
{ headers: { "Content-Type": "application/json" } },
)
})
error: Uncaught (in promise) Error: The module's source code could not be parsed: Expected ';', got 'Response' at file:///src/index.ts:194:16
const ret = new Error(getStringFromWasm0(arg0, arg1));
^
at __wbg_new_8d2af00bc1e329ee (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:312:19)
at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:79439)
at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1388039)
at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1862894)
at __wbg_adapter_18 (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:146:6)
at real (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:130:14)
every variation of this fails to compile. Can someone help me out here please?nav
12/20/2022, 11:15 PMrayctf
12/20/2022, 11:33 PMemileon
12/21/2022, 3:37 AMVik
12/21/2022, 4:15 AM// Get the public URL
const { data } = await supabase.storage
.from('avatars')
.getPublicUrl(filePath);
// Update the users public profile with the new avatar URL
const { data: updatedUserProfile, error: updatedUserProfileError } =
await supabase
.from('profiles')
.update({ avatar_url: data.publicUrl })
.eq('id', userID)
.select();
if (updatedUserProfileError) {
throw Error('User profile was not updated with new avatar URL.');
}
setUserProfile(updatedUserProfile);
frozenPresence
12/21/2022, 4:59 AMfrozenPresence
12/21/2022, 5:05 AMfrozenPresence
12/21/2022, 5:12 AMVik
12/21/2022, 5:18 AMconst filePath = `${userID}/avatar`;
// Append the data to the formData class
formData.append('file', imageData);
// Upload or replace existing users avatar
let { error } = await supabase.storage
.from('avatars')
.upload(filePath, formData, {
upsert: true,
});
// Handle any errors that may occurr
if (error) {
throw Error('Image upload failed.');
}
jar
12/21/2022, 5:37 AMconst { data, error } = await supabase
.storage
.from('avatars')
.list()
returns 100. How can I simply get the other 70... This is example from docs. I have no folders and can't find a variation that works
const { data, error } = await supabase
.storage
.from('avatars')
.list('folder', {
limit: 100,
offset: 0,
sortBy: { column: 'name', order: 'asc' },
})
Why cant this work. I have no sub folder
const { data, error } = await supabase
.storage
.from('avatars')
.list({
limit: 100,
offset: 0,
sortBy: { column: 'name', order: 'asc' },
})