https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Run authenticated SQL query
    c

    chaoky

    04/18/2023, 11:11 PM
    Hi, I want to run raw sql queries against postgres, but still use the jwt authentication provided by gotrue. Is the verification of the jwt taking place in a postgres function or do I have to verify the jwt against gotrue first?
    g
    • 2
    • 11
  • Database trigger function returns error
    c

    chris

    04/19/2023, 12:04 AM
    I've used supabase last year and had no problems. Started using it again and I get an error: "permission denied for table users" when I run a trigger to insert the email to a public.users table after someone signs up. There is no rls on the users table so this seems weird to me This is the code: -- inserts a row into public.users CREATE FUNCTION public.handle_new_user() RETURNS TRIGGER LANGUAGE plpgsql SECURITY DEFINER SET search_path = public AS $$ BEGIN INSERT INTO public.users (email) VALUES (new.email); RETURN new; END; $$; -- trigger the function every time a user is created CREATE TRIGGER on_auth_user_created AFTER INSERT ON auth.users FOR EACH ROW EXECUTE PROCEDURE public.handle_new_user();
    g
    • 2
    • 5
  • Multiple User Types / Tables (ie. AWS Cognito User Pools)
    z

    zlanich

    04/19/2023, 12:16 AM
    I'd like to start a discussion here to nail down the best way to handle multiple user types in Supabase Auth. This is the only resource I've found, and it contains possible ways in doing so, but does not use separate user tables (which may or may not be ideal): https://github.com/orgs/supabase/discussions/12647 Let's start with a use-case and work from there. I own a mobile parking app, so we'll use that as an example: - Mobile app for customers who park their vehicles - Administrative dashboard for parking authority users who will have roles/permissions per parking authority - Administrative dashboard for users who administer the system itself (company owners) In AWS Cognito, it would be common to create 3 separate user pools for this to keep the user types and their respective properties separate. So there would never be crossover between say a customer user and a full system administrator (nor should there be). It would be ideal to keep these concerns separated for the following reasons: - Keeping them fully separate would severely reduce the likelihood of security issues regarding privilege escalation from a customer user to a full system administrator - It's very common for different types of users who perform very different actions to have different properties on the user table (you could use a meta table for that if desired) - If you wanted to delete an administrative user, and that user also happened to have a customer user account, you wouldn't want it to delete the customer user account as well. You would just want to revoke all of their administrative presence. - You wouldn't want password changes, etc to affect their other accounts when that wouldn't be the desired or expected behavior My Supporting Misc Thoughts: - Semantically, the 3 user interfaces would seem like 3 separate applications, but there's really no reason to provision, pay for and maintain 3 Supabase instances JUST to get around this, especially when there will be a ton of shared logic on the backend - I don't yet know where all the limitations are regarding Supabase Auth and its connection to Postgres, but it seems like it would be ideal to have 3 auth user tables and some flag that tells the sign ups and queries which user table to use. Let's chat!
    g
    • 2
    • 1
  • UPDATE requires a WHERE clause error when using supabase-js
    c

    calvinbutternut

    04/19/2023, 1:38 AM
    const { error } = await supabase .from('events') .update(data) .eq('id', eventId); However when I make this call, I'm getting this error: {"code": "21000", "details": null, "hint": null, "message": "UPDATE requires a WHERE clause"} My data and eventId variables on an example call look like this: "eventId": 99 "data": {"resolved_at": "2023-04-19T00:57:52.221Z", "status": "resolved", "updated_at": "2023-04-19T00:57:52.221Z", "winning_outcome_id": 162} Can anybody help me debug?
    g
    • 2
    • 35
  • error: bouncer config error
    p

    pusha007

    04/19/2023, 2:23 AM
    Hello, Why I get this error ?
    Copy code
    error: bouncer config error
    setup
    Copy code
    const pool = new Pool({
        host: 'db.xxx.supabase.co',
        user: 'postgres',
        database: db_name ?? 'postgres',
        password: 'xxx',
        ssl: { rejectUnauthorized: false },
        port: 6543,
        min: 0,
        max: 10,
        createTimeoutMillis: 8000,
        acquireTimeoutMillis: 8000,
        idleTimeoutMillis: 0,
        connectionTimeoutMillis: 0,
        reapIntervalMillis: 1000,
        createRetryIntervalMillis: 100,
      });
    
      return pool;

    https://cdn.discordapp.com/attachments/1098071358627393576/1098071358795161652/sppp.PNG▾

  • Issues with flutter SDK
    d

    DRUNKGURU

    04/19/2023, 3:32 AM
    New dev here. As soon as I introduce the supabase_flutter 1.7.0 library into the project, I immediately have build issues. In both iOS and Android. What's the deal ? #1006358244786196510 [ ――― TEMPLATE END ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― [!] Oh no, an error occurred. Search for existing GitHub issues similar to yours: https://github.com/CocoaPods/CocoaPods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle%2C+0x0009%29%3A+tried%3A+%27%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle%27+%28mach-o+file%2C+but+is+an+incompatible+architecture+%28have+%27x86_64%27%2C+need+%27arm64%27%29%29%2C+%27%2FSystem%2FVolumes%2FPreboot%2FCryptexes%2FOS%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle%27+%28no+such+file%29%2C+%27%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle%27+%28mach-o+file%2C+but+is+an+incompatible+architecture+%28have+%27x86_64%27%2C+need+%27arm64%27%29%29+-+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle&type=Issues If none exists, create a ticket, with the template displayed above, on: https://github.com/CocoaPods/CocoaPods/issues/new Be sure to first read the contributing guide for details on how to properly submit a ticket: https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md Don't forget to anonymize any private data! Looking for related issues on cocoapods/cocoapods... Error output from CocoaPods: ↳ Searching for inspections failed: undefined method `map' for nil:NilClass [!] Automatically assigning platform
    iOS
    with version
    11.0
    on target
    Runner
    because no platform was specified. Please specify a platform for this target in your Podfile. See
    https://guides.cocoapods.org/syntax/podfile.html#platform
    . Error running pod install Error launching application on iPhone 14 Pro Max.]
  • Creating trigger to delete auth user
    k

    KurustyKrabs

    04/19/2023, 5:46 AM
    Hi all, I'm trying to make a trigger to delete auth_user when there's a deletion on data in one table. For example, I have a table called users and this table contains extended data from the auth_users data. Whenever there's deletion in the users table, it will trigger automatically to delete the auth_users in relation with the data that have been deleted from the users table. My query is as following but it displayed invalid SQL query. Still learning how to write query properly, apologies in advance. CREATE or replace function delete_user() returns void LANGUAGE SQL SECURITY DEFINER AS $$ --delete from public.profiles where id = auth.uid(); delete from auth.users where id = auth.uid(); $$; CREATE trigger users after delete id on users for each row execute procedure delete_user();
    g
    • 2
    • 3
  • User Meta Data Problem
    j

    justJosuke

    04/19/2023, 6:19 AM
    I am currently trying to create a database for a social media app, and I am struggling with creating a function for when a new user is created. When a new user is created, I want the user to provide their email, password, and username. I am using Draftbit to structure my requests using JSON format. { "email": {{signupEmail}}, "password": {{signupPassword}}, "data": { "username": {{username}}, } } I want to create a function to insert the id, email, and username into a table. I have tried messing with it, but it always gives 500 error messages. Here I have provided the definition that I have for my function: begin insert into public.users (user_id, email, username) values (new.id, new.email, new.raw_user_meta_data->>'username'); return new; end;
    g
    • 2
    • 2
  • Supabase Storage Egregious Egress
    m

    monitor

    04/19/2023, 6:22 AM
    Due to some egregious useEffect react code that ran in a loop, I made some 300,000 download requests to a storage bucket for a 30 kb image in my supabase project (about 24 hours ago). However, this appeared to not approach anywhere near the total egress limit, until about a few minutes ago when it suddenly said project has exceed usage limits. How can I verify what the cause of the sudden ~5gb egress is?
    s
    • 2
    • 1
  • API is not exposed under graphql
    k

    krishnaprasad2098

    04/19/2023, 9:03 AM
    I created a table using ui and another using sql.But the table created using ui is only exposed in graphql. The other one is not exposed. And the graphql client says that { "data": null, "errors": [ { "message": "Unknown field \"departmentsCollection\" on type Query" } ] }
    g
    • 2
    • 1
  • Authentication with Discord
    k

    khanhdq

    04/19/2023, 9:09 AM
    Hi there I'm using Discord to login with supabase redirects url. I'm already get these field in the callback url. I'm trying with https://discord.com/api/users/@me and set the access_token in the bearer token but still got Unauthorized.
    Copy code
    {
      "message": "401: Unauthorized",
      "code": 0
    }
    s
    g
    • 3
    • 5
  • Exceeded project usage limits by myself in 1 week?
    c

    Cheqo

    04/19/2023, 11:12 AM
    Hello, I am working on one of my supabase projects and just realised that I exceeded
    storage egress
    by 2.5gb, however it was only me and its been less than 2 weeks. I do have a lot of images to work with, but surely 1 user can't consume that much anyways or can they?

    https://cdn.discordapp.com/attachments/1098204435127222343/1098204435370487818/Screenshot_2023-04-19_at_12.03.12.png▾

    g
    • 2
    • 6
  • basic policy
    a

    Ariyan

    04/19/2023, 11:31 AM
    Hey everyone. I just created a table called "users" which i store user id and email. and I'm managing it from my flask app. first time i tried inserting the data from my app i got the `` {'code': '42501', 'details': None, 'hint': None, 'message': 'new row violates row-level security policy for table "users"'} `` error and then findout i need to create a policy. then i created this policy but it still doesn't work
    Copy code
    CREATE POLICY "Allow authenticated users" ON "public"."users"
    AS PERMISSIVE FOR ALL
    TO authenticated
    USING (true)
    WITH CHECK (true)
    i just want to be able to fetch the data and insert data from my app. it's a simple app and i'm the only one having access to my supabase dashboard.
    g
    • 2
    • 3
  • 'Post' table foreign key auth.users table
    p

    pippin_mole

    04/19/2023, 11:34 AM
    I have a database table called ``posts`` which has a foreign key to the auth.users table on ``author_id``. How do I generate a Typescript query that joins that user object with the post? So that the json would look like this:
    Copy code
    json
    {
      error: null,
      data: {
        id: 10,
        created_at: '2023-04-18T23:19:26.106773+00:00',
        title: 'This is a title',
        content: 'This is content',
        images: [],
        author: {
          email: "...",
          ...
        }
      },
      count: null,
      status: 200,
      statusText: 'OK'
    }

    https://cdn.discordapp.com/attachments/1098210081524437104/1098210081763491870/Screenshot_2023-04-19_at_12.31.15.png▾

  • Edge Functions Database Webhooks
    q

    quintin

    04/19/2023, 1:21 PM
    I see on the supabase edge functions website (https://supabase.com/edge-functions) that database webhooks are supported --> "Invoke Edge Functions based on any event in your database." I am trying to find some documentation on this and have been unsuccessful so far. Can someone please point me to the right place?

    https://cdn.discordapp.com/attachments/1098236984587206686/1098236984935321631/image.png▾

    g
    • 2
    • 1
  • Consistent retrieval of foreign key for a 'Posts' table
    p

    pippin_mole

    04/19/2023, 1:41 PM
    I have a 'Posts' table that foreign keys a user in Supabase Auth. How do I consistently 'retrieve' a Post with the user entry too? An example: I have a component that takes a 'Post' instance as a prop. How does this component render, for example, the author's email? Currently the post model only shows the author's ``id``, which isn't very useful for frontend.
    g
    • 2
    • 11
  • In supabase, for an email field, should I use varchar or text? (Postgres)
    v

    Vadorequest

    04/19/2023, 1:57 PM
    I asked ChatGPT, which recommends varchar, do you agree? Can I run into troubles by selecting varchar today? I didn't find how/where to set the char limit when using varchar.

    https://cdn.discordapp.com/attachments/1098246043214282943/1098246043503710229/image.png▾

    g
    • 2
    • 3
  • Auth: create initialSession with cookie for SessionContextProvider
    j

    jabza

    04/19/2023, 1:58 PM
    Hi, I am trying to have the session established on the server side first-render using cookies in my NextJS app. I have the cookie which clearly contains the Auth session - how would I go about providing the 'initalSession' object for EssionContextProvider? Thank!
    • 1
    • 2
  • Advice for setting up foreign keys to support joins
    l

    lambbear

    04/19/2023, 2:25 PM
    Right now I am using the auth schema users.id as my foreign_key in all my tables. I have the standard 'profiles' table which serves the purpose of saving user data in my public schema. But instead of using the profile_id in other public tables, i am using the user_id. The problem i'm running into is when i want to run a query that requires a join (for example to fetch data from the profiles table and from some extra_data table) I want to use the user_id column to join them, but the standard easy supabaseJS syntax isn't detecting a foreign_key relationship because technically there isn't one between these two tables. They both are using user_id as their foreign_key. The question is, is there some syntax i can use to indicate that the join should happen on this user_id column? Have i made a mistake in setting up my database and perhaps user_id should only be used on my profiles table, and everywhere else i should be referencing profile_id? I thought it would make sense to use user_id everywhere since I always have it from the supabase session. I didn't want to have to query the profile table if i wasn't selecting data from it.
    g
    v
    • 3
    • 6
  • Generating types and table through Supabase CLI w/ foreign key constraint
    p

    pippin_mole

    04/19/2023, 2:40 PM
    I have a 'posts' table that foreign keys a 'profiles' table through an ``author_id`` uuid. When I run the CLI command to get my ``schema.ts`` file, there is no sign of a type matching my foreign key table. How do I access this field in typescript without errors stating the field does not exist

    https://cdn.discordapp.com/attachments/1098256941131759636/1098257909189705818/Screenshot_2023-04-19_at_15.44.21.png▾

    g
    • 2
    • 2
  • Policy to update one foreign key
    c

    Cadavreux

    04/19/2023, 2:54 PM
    Hi everyone, I am having trouble implementing a new policy. There is a table1, with a foreign key from auth, users table (id) I want to be able to update it, to change the user that is link to the row of table 1, to a unique value. For now, i can update other column but not the foreign key one. I just want my edit to modify the table 1 and do nothing on the user one, except checking if user exist. Any help?
    g
    • 2
    • 1
  • Update value to NULL using supabase-swift
    w

    ws

    04/19/2023, 5:02 PM
    When I try to update values to NULL with nil, they're ignored
  • createBrowserClient() not reading .env variables.
    z

    zach

    04/19/2023, 5:05 PM
    Context: 1) NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY are defined in .env.local in the root of my NextJS project. 2) In my _app.js (as reccomended by Supabase documentation) is where I call createBrowserSupabaseClient() in a supabaseClient useState variable. Problem: But, when I try to run the app in dev mode, I get this error:
    Error: either NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY env variables or supabaseUrl and supabaseKey are required!
    Can someone tell me what I'm missing? I've also defined a server side client with createClient() in root > utils > supabase.js (also attached).

    https://cdn.discordapp.com/attachments/1098293423070527589/1098293423468982272/Screenshot_2023-04-19_at_1.00.35_PM.png▾

    https://cdn.discordapp.com/attachments/1098293423070527589/1098293423729025064/Screenshot_2023-04-19_at_1.00.14_PM.png▾

    https://cdn.discordapp.com/attachments/1098293423070527589/1098293423984885800/Screenshot_2023-04-19_at_1.04.18_PM.png▾

    • 1
    • 1
  • Can we run upsert via REST/GraphQL?
    v

    Vadorequest

    04/19/2023, 5:14 PM
    I cannot use the Supabase nodejs module because I'm running a script in the context of an Airtable automation. Can I run an upsert operation using either of the REST/GraphQL api directly? How can I do that?
    g
    • 2
    • 1
  • How to set column min/max length?
    v

    Vadorequest

    04/19/2023, 5:23 PM
    I have a column "authPIN" which is always 6 chars. How do I enforce this at the database level? I tried asking Copilot, but it either uses "varchar" which isn't what I want (apparently, varchar shouldn't be used, and regardless, it would only help handle the max length, not the min length)

    https://cdn.discordapp.com/attachments/1098297889085722685/1098297889324806174/image.png▾

    g
    • 2
    • 2
  • Trigger when a user authenticates
    b

    brassotron

    04/19/2023, 5:34 PM
    Hello, I'm trying to send a security notice email via an edge function when a user authenticates, but I only want this to happen on fresh sessions, not refreshes. If I trigger on auth.sessions INSERT would this achieve that or are there other scenarios where an INSERT would fire? Thanks!
    g
    • 2
    • 2
  • Password Reset
    s

    shutupyafoo

    04/19/2023, 6:17 PM
    The password reset link on the login page of supabase does not send emails. I have been trying to get my password reset for some time now, but no email allowing me to rest my password arrives
    g
    s
    s
    • 4
    • 8
  • RLS Authenticated role
    j

    jinsley8

    04/19/2023, 7:01 PM
    what is considered 'authenticated' in the user roles? Is this the authenticated role in the users auth table or just when the supabase JWT is passed for a session? I had to setup custom auth using
    next-auth
    and followed this guide. I'm sending
    role: authenticated
    in the supabase JWT so these users would be detected in RLS as authenticated correct? https://authjs.dev/reference/adapter/supabase#enabling-row-level-security-rls

    https://cdn.discordapp.com/attachments/1098322579279843439/1098322579598618754/Screenshot_2023-04-19_at_2.57.30_PM.png▾

    r
    • 2
    • 4
  • How can I pass OAuth from Webapp to chrome extension?
    n

    nova

    04/19/2023, 7:21 PM
    I am currently building a Chrome Extension and would like to leverage my existing website for authentication. I have tried passing the refresh and access tokens using `onMessageExternal `and use `setSession `but that does not seem to sign in the user on the chrome background script side. Any suggestions?
    g
    r
    • 3
    • 2
  • transfer project
    r

    Robert Dylina

    04/19/2023, 7:48 PM
    The docs say there should be a transfer ownership function in the project settings but I don't see anything. I want to transfer a project from my hobby org to my paid org. Any thoughts?
    s
    n
    • 3
    • 4
1...185186187...230Latest