TARS
08/13/2022, 1:05 PMfunction MyApp({ Component, pageProps }) {
const [session, setSession] = useState(null);
useEffect(() => {
setSession(supabase.auth.session());
supabase.auth.onAuthStateChange((_event, session) => {
setSession(session);
});
}, []);
return (
<>
{!session ? (
<Login />
) : (
<SideBarProvider>
<Layout>
<Component {...pageProps} key={session.user.id} session={session} />
</Layout>
</SideBarProvider>
)}
</>
);
}
Amos
08/13/2022, 2:32 PMgorbypark
08/13/2022, 6:01 PMoxlory
08/13/2022, 7:30 PMGruce
08/13/2022, 9:48 PMprofiles
table which has points
column when an authenticated user buy an item inside the app I need to subtract the item price
from points
and then add item id
to users_items
table. If has less points he can't get that item.
How could I do that from a security prospect? Because if I do it from frontend he could add it directly from POSTMan or any post request.
Thank you.kevindmoore
08/13/2022, 10:43 PM49Ryann
08/14/2022, 3:12 AMconst match = `
*,
children:contact_and_type!parent_id(
id,
type,
contact:child_id(id, full_name, profile_image)
),
parent:contact_and_type!child_id(
id,
type,
contact:parent_id(id, full_name, profile_image)
)`
I currently just get the first value but I don't really like this approach:
contact.parent = contact.parent[0]
LEGEND
08/14/2022, 8:13 AMosener
08/14/2022, 9:35 AMhttps://<app>.supabase.co/auth/v1/callback?code=...&state=...
. Is this stored in the DB?
I would like to avoid forcing users to go through Notion OAuth flow twice, once for supabase auth and another time for API access.
Thanks in advance!onlyafly
08/14/2022, 10:07 AMWaldemar
08/14/2022, 10:54 AMhttps://abghekjureweajqqcvks.supabase.co/storage/v1/object/public/public/foo.jpg
I've run the test several times using this tool:
https://speedvitals.com/ttfb-test
The difference for example from Los Angeles is huge:
1.3s Supabase Storage VS 96ms DigitalOcean Spaces.
It's slower significantly on average across all other test locations.
Am I doing something wrong? Is there a different URL for CDN? Like via from.list()
in JS client?Deleted User
08/14/2022, 11:52 AMclient.auth.signUp({ provider: 'github' })
in JS, it throws a 422 saying Signup requires a valid password
. I don't need to provide a password when using github signup right?samuele
08/14/2022, 5:21 PMimousart
08/14/2022, 5:29 PMSparK
08/15/2022, 1:10 AMedelacruz
08/15/2022, 6:28 AMvvpavle
08/15/2022, 7:41 AMstukennedy
08/15/2022, 10:18 AMsveltekit-magic-link
example
My query looks like this
ts
export const POST = async ({ request, locals }: RequestEvent) =>
withApiAuth({ user: locals.user }, async () => {
const data = await request.formData();
const title = data.get('title') as string;
supabaseServerClient(request).from('projects').insert([{ title }]);
return {
body: { user: locals.user }
};
});
I get a 403 back from the endpoint with error
js
{
...
message: 'new row violates row-level security policy for table "projects"',
...
}
I print out locals.user just before the call and it is authenticated.
I can't find any API documentation on the auth-helpers project, just the example in the README and the examples folder.
But I'm guessing the withApiAuth({ user: locals.user }, ... ) call is setting the user from there, so don't know why my RLS isn't working
there is a note in the user object
js
'supabase-auth-helpers-note': 'This user payload is retrieved from the cached JWT and might be stale. If you need up to date user data, please call the getUser method in a server-side context!',
but none of the examples do that ... they just use locals.user.
So I tried getUser
... it returns an authenticated user and all looks good, but I still get the same RLS error.
Any ideas?Jaaneek
08/15/2022, 11:05 AMJesse
08/15/2022, 1:23 PMtrebor
08/15/2022, 4:07 PMSizzlingSquiggle
08/15/2022, 5:03 PMTARS
08/15/2022, 5:23 PMavalanche
08/15/2022, 6:52 PMsql
create or replace function search_items(lang regconfig, query text)
returns table (id uuid, title text, location point, price numeric(16,2), currency_id bigint, thumbnail text)
language plpgsql
as
$$
declare
query_vector tsquery = to_tsquery(lang, query);
begin
return query
select
a.id,
a.title,
a.location,
a.price,
a.currency_id,
a.thumbnail
from item a,
lateral create_fts_vector(a.title, a.description, lang) weighted_fs_vector
where weighted_fs_vector @@ query_vector
order by ts_rank(weighted_fs_vector, query_vector)
desc;
end;
$$;
I'm trying call my function and join it with currency table which has id and value:
dart
return _client
.rpc('search_items',
params: {'lang': 'italian', 'query': queryText})
.select(
'id, title, location, price, currency(id, value), thumbnail')
.execute()
I'm getting error: Could not find a relationship between 'pgrst_source' and 'currency' in the schema cache.
What am I doing wrong? How can I join table based on id I get in rpc call? Currency table has primary key id.dmytro.eth
08/15/2022, 7:09 PMsupabase init
and supabase start
and after it started, it exposed some of the environmental secrets in my terminal. However, I can't find a JWT secret value anywhere? Is it available in the local instance?nickbrinser
08/15/2022, 7:52 PMgetUserByCooke
and shows cookie not found even when authenticated. This is due to updates made to the NextRequest
type.
Not a huge deal since you can use the auth-helpers-nextjs
getUser
in it's place, but thought I should share this.
I know auth-helpers-nextjs
does not currently support NextJS 12.2.X, but I have a PR open with the required updates.FragAverage
08/15/2022, 8:03 PMe0
08/15/2022, 8:04 PMsupabase gen types typescript --db-url MY_DB_URL
and I get the following message: Error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
. I figured that docker is only needed for local projects but is it actually required for generating types for remote instances as well?Derek
08/15/2022, 11:48 PMbhaskar
08/16/2022, 12:09 AM