totem
04/23/2023, 9:40 PMRares | Foton • Teeps
04/23/2023, 10:26 PMmalphine2
04/23/2023, 11:47 PMquintin
04/23/2023, 11:50 PMhttps://cdn.discordapp.com/attachments/1099844764939079761/1099844765178146847/image.png▾
https://cdn.discordapp.com/attachments/1099844764939079761/1099844765400449105/image.png▾
jdgamble555
04/24/2023, 1:14 AMts
export let data: LayoutData
$: ({ supabase, session } = data)
...
onMount(() => {
const { data } = supabase.auth.onAuthStateChange((event, _session) => {
if (_session?.expires_at !== session?.expires_at) {
invalidate('supabase:auth')
}
})
return () => data.subscription.unsubscribe()
})
I'm trying to figure out why I even need onAuthStateChange
at all? I already have the session variable from the server... if I need to re-fetch data, won't it just automatically update the session on the server? When would a session created on the server and passed to the client not be equal to each other? I'm confused why this is here...
Jvjoohov
04/24/2023, 2:27 AMscook
04/24/2023, 3:26 AMcreated_by
field when inserting an item. I have followed this guide: https://supabase.com/docs/guides/auth/auth-helpers/nextjs-server-components#route-handlers.
However, when I use either createRouteHandlerSupabaseClient
or createServerSideClient
to get the client, they both give me {"data":{"session":null},"error":null}
when I use client.auth.getUser()
.
I also tried getting the session with client.auth.getSession()
, but that gave me: {"data":{"user":null},"error":{"name":"AuthApiError","message":"invalid claim: missing sub claim","status":401}}
.
I should note that I tested retrieval of the user/session in three other spots: 1) app shell layout that sets up the SupabaseProvider/SupabaseListener, 2) middleware, and 3) client-side components. All of them successfully get the user as expected. See screenshots for that code.
FWIW another strange behavior is that the route handler works correctly on local but not on the staging environment.
TIA!
https://cdn.discordapp.com/attachments/1099899130500882512/1099899131159384125/Screenshot_2023-04-23_at_8.07.17_PM.png▾
https://cdn.discordapp.com/attachments/1099899130500882512/1099899131457183805/Screenshot_2023-04-23_at_8.07.35_PM.png▾
https://cdn.discordapp.com/attachments/1099899130500882512/1099899131788529754/Screenshot_2023-04-23_at_8.09.40_PM.png▾
Ankur
04/24/2023, 3:48 AM4thPerson
04/24/2023, 7:43 AMshnoman
04/24/2023, 7:49 AMbenemanu
04/24/2023, 8:47 AMJimotron
04/24/2023, 9:40 AMawait supabase.auth.signInWithOAuth({
provider: "github",
options: {
redirectTo: window.location.href,
},
});
await supabase.auth.signInWithOtp({
email,
options: {
emailRedirectTo: window.location.href
},
});
The login is working except both methods redirect me to myapp.com instead of to the subdomain.gaborcs
04/24/2023, 9:53 AMamilkov
04/24/2023, 12:12 PMsupabase start
but then no docker port is exposed (i believe it should just be 4000)...is this intentional. i get a bunch of failures when attempting to --exclude realtime
and then cloning the realtime repo and manually running the docker compose but id rather not do all that since its more of a nuisance to develop locally. is there some simple way to expose 4000:4000
with args to supabase start
or something?
2) supabase sockets in prod arent doing anything. i double checked my server side code is executing:
const realtime = new RealtimeClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!.includes('localhost')
? 'ws://localhost:4000/socket'
: `wss://${process.env.NEXT_PUBLIC_SUPABASE_PROJ_REF}.supabase.co/realtime/v1`,
{
params: { apikey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY },
},
);
realtime.connect()
const x = realtime.channel('onchain').subscribe();
await x.send({
type: 'broadcast',
event: 'onchain',
payload: { agreementId: agree.id },
});
but i see nothing in the realtime logs in the web studio and the client definitely isnt receiving any eventsWALTERB
04/24/2023, 1:35 PM<div class="navbar">
<button id="signed" onclick="signin()">Sign in with discord</button>
<button id="out" class="right" onclick="signout()">Sign out with discord</button>
</div>
<p id="name">Not logged in!</p>
MY JS:
const _supabase = supabase.createClient(supabaseUrl, supabaseKey)
async function signin() {
const {data, error} = await _supabase.auth.signInWithOAuth({
provider: 'discord',
})
checking()
}
async function getName() {
const {data: {user}} = await _supabase.auth.getUser()
const fullName = user.user_metadata.full_name
document.getElementById('name').textContent = `${fullName} `
checking()
}
getName()
async function signout() {
const {error} = await _supabase.auth.signOut()
document.getElementById('name').textContent = "Not logged in!"
alert("Signed out!")
checking()
}
Consti Constantin
04/24/2023, 1:38 PMEmbm
04/24/2023, 2:10 PMwhoami
04/24/2023, 3:11 PMsupabase.storage
.from('public')
.upload(file.name, file)
.then(({ error }) => {
console.log('upload error', error)
if (error) {
snackbar.error(
'There was an error uploading the file, please try again later',
)
return
}
})
and got
Object { statusCode: "500", error: "Database Error", message: 'invalid input syntax for type uuid: "user_2OHvEF7KJkNHo7fIirckoCSf9D4"' }
Note that my requests is normal in non storage operations, and looks like supabase storage is going through a different auth that reads sub field in the JWT token, I tried remove all the RLS in storage and the problem still exist (it is not related to RLS, the problem seem to happen before that). I decoded the JWT token in the header, and the sub
part is the user id starts with user...
, I am wondering if this can be resolved by defining some kind of custom function in storage to resolve that.metafoo
04/24/2023, 3:50 PMauth.uid()
with objects.name
.
To know whether a certain user actually has uploaded an avatar while showing/listing (without joining data or producing N+1 queries), I added a flag has_avatar
to my profiles
table.
To automatically keep track of that flag, I added the following functions + triggers, to update the flag accordingly on every upload/delete of an avatar:
CREATE OR REPLACE FUNCTION public.set_profiles_has_avatar_flag()
RETURNS trigger
LANGUAGE plpgsql
AS $function$BEGIN
UPDATE public.profiles
SET has_avatar = true
WHERE id::text = new.name;
RETURN new;
END;$function$
;
CREATE OR REPLACE FUNCTION public.unset_profiles_has_avatar_flag()
RETURNS trigger
LANGUAGE plpgsql
AS $function$BEGIN
UPDATE public.profiles
SET has_avatar = false
WHERE id::text = new.name;
RETURN new;
END;$function$
;
CREATE TRIGGER set_profiles_has_avatar_trigger AFTER INSERT ON storage.objects FOR EACH ROW EXECUTE FUNCTION set_profiles_has_avatar_flag();
CREATE TRIGGER unset_profiles_has_avatar_trigger AFTER DELETE ON storage.objects FOR EACH ROW EXECUTE FUNCTION unset_profiles_has_avatar_flag();
The first one (setting the flag) works like a charm, but the flag doesn't get unset on delete. (The function is actually being called, tested by test-wise producing an error within it)
I don't geeeeeet it.
Any ideas? 🙂ajdavies
04/24/2023, 4:19 PMhttps://cdn.discordapp.com/attachments/1100093690267041843/1100093690854248558/Screenshot_2023-04-24_at_17.17.16.png▾
https://cdn.discordapp.com/attachments/1100093690267041843/1100093691105902682/Screenshot_2023-04-24_at_17.10.09.png▾
https://cdn.discordapp.com/attachments/1100093690267041843/1100093691340800180/Screenshot_2023-04-24_at_17.07.54.png▾
SunTzu
04/24/2023, 4:24 PMcreate table api_keys (
id bigint generated by default as identity primary key,
created_at timestamp with time zone default timezone('utc'::text, now()) not null,
updated_at timestamp with time zone default timezone('utc'::text, now()) not null,
name text,
apikey text,
key_id uuid not null DEFAULT 'a-value-here'::uuid
);
SECURITY LABEL FOR pgsodium
ON COLUMN api_keys.apikey
IS 'ENCRYPT WITH KEY COLUMN key_id';
However when I try to insert into the table I get the error:
``"permission denied for function crypto_aead_det_encrypt"``
Any ideas what the problem is??Razoth
04/24/2023, 5:13 PMpetoma
04/24/2023, 5:32 PMgetStudents: builder.query({
queryFn: async (args) => {
const { course, speciality } = args;
const {data: rawData, error} = await supabase
.from('students')
.select(`
*,
course:students_courses (
course_id (
name_course
)
),
speciality:students_speciality (
speciality_id (
name_speciality
)
)
`);
const formattedData = rawData.map(student => ({
...student,
course: student.course.map(courseObj => courseObj.course_id.name_course),
speciality: student.speciality.map(specialtyObj => specialtyObj.speciality_id.name_speciality)
}));
return { data: formattedData, error };
},
providesTags: ["Students"]
}),
I would like to find a way to conditionally add a query if some value comes in args. Something like .eq("curso_id",curso)
Thank you!0xFuru
04/24/2023, 5:50 PMCripyIce
04/24/2023, 6:35 PMApollo
04/24/2023, 6:40 PM0xAsimetriq
04/24/2023, 7:04 PMVik
04/24/2023, 7:44 PMTater Of Tots
04/24/2023, 7:52 PMosamita
04/24/2023, 8:34 PM