https://supabase.com/ logo
Join DiscordCommunities
Powered by
# off-topic
  • t

    Terry

    11/10/2021, 12:59 PM
    Aha! https://nikofischer.com/supabase-how-to-query-users-table β€”Β create a public users table + a trigger to keep it updated! Sweet!
  • s

    silentworks

    11/10/2021, 1:01 PM
    Be wary that the article is missing a vital step which could break this, if the user was to change their email, it won't be changed in the profiles table, you need to create another trigger to make sure that is kept up to date or make sure you make an additional call to update the email in the profiles table
  • t

    Terry

    11/10/2021, 1:02 PM
    ooo that's a good one! Thank you!
  • c

    chipilov

    11/10/2021, 1:43 PM
    depending on you scenario you might not need to keep 2 tables in sync - just create a view in the public schema which references the users table in the auth schema. However, you still need to ensure that you don't leak user info to the wrong users (not sure if you can define RLS on the auth.users table, but even if you cannot, you can protect the data on the view definition level with an additional clause)
  • s

    silentworks

    11/10/2021, 1:46 PM
    I don't think RLS work on views from what I remember, so yeah be careful of the data you make available in them
  • c

    chipilov

    11/10/2021, 1:49 PM
    Indeed, you cannot define RLS for a view, however, as long as the definer of the view does NOT bypass RLS policies in general, the view will respect the RLS of the underlying table
  • l

    letourpowerscombine

    11/10/2021, 1:52 PM
    When I run this function, a user is created as expected in the
    users
    table with a new UUID β€” but the returned value is
    null.
    Copy code
    let { user, error } = await supabase.auth.signIn({
            email: formData.get('email')
          })
    Is there anyway to return the newly created user's UUID / user object from this function? (I have turned off "Enable email confirmations" in the auth settings, to make it easier)
    s
    y
    • 3
    • 72
  • s

    silentworks

    11/10/2021, 2:25 PM
    @User can I DM you?
  • c

    chipilov

    11/10/2021, 2:51 PM
    Yep...do I need to enable something? I tried DM-ing you but the message could not be delivered
  • y

    YelloJello

    11/10/2021, 4:41 PM
    This is more of a "what the hell is happening" kind of question, but when you create a new schema, add it via the dashboard and create a client to open a connection to that schema only, if you use the service role key do you have to grant usage and privileges to the appropriate role yourself? It seems like it, because I had to do this myself because supabase would keep sending 403 responses for every request I made. I tried this with the anonymous key too. What exactly does adding a schema via the dashboard do? This isn't enough explanation imo:
    The schema to expose in your API. Tables, views and stored procedures in this schema will get API endpoints.public and storage are protected by default.
    The bits in the blog post and the couple sentences in the docs don't do enough either imo What does it mean by "protected by default"? Does it have something to do with grants?
    j
    g
    • 3
    • 5
  • l

    letourpowerscombine

    11/10/2021, 4:53 PM
    I'm trying to add rows to
    profiles
    table when new users are added, including metadata like
    email address
    ,
    name
    ,
    website
    , all through the initial sign up function. So creating a new user like this:
    Copy code
    javascript
          const { data, error } = await supabase.auth.signIn(
            { email: localStorage.getItem('email') },
            {
              data: {
                full_name: formData.get('full_name'),
                introduction: formData.get('introduction'),
                website_url: formData.get('website_url'),
                linkedin_url: formData.get('linkedin_url'),
                twitter_handle: formData.get('twitter_handle'),
                contact_method: formData.get('contact_method')
            }
          })
    And handling it like this:
    Copy code
    sql
    create function public.handle_new_profile()
    returns trigger as $$
    begin
        insert into public.profiles (user_id, user_email, full_name, introduction, website_url, linkedin_url, twitter_handle, contact_method )
        values (new.id, new.email, new.raw_user_meta_data->>'full_name', new.raw_user_meta_data->>'introduction', new.raw_user_meta_data->>'website_url', new.raw_user_meta_data->>'linkedin_url', new.raw_user_meta_data->>'twitter_handle', new.raw_user_meta_data->>'contact_method');
        return new;
    end;
    $$ language plpgsql security definer;
    
    -- 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_profile();
    Currently, new rows in
    profiles
    are created when the function is called β€” but they only contain the
    user_id
    and
    user_email
    fields, none of the other data. I feel like this might be some syntax error in the
    public.handle_new_profile()
    function, not receiving the user metadata or int it the right way. Can anybody suggest a troubleshoot/fix?
    y
    s
    m
    • 4
    • 10
  • y

    YelloJello

    11/10/2021, 5:13 PM
    setting metadata when using magic link auth
  • a

    adhi256

    11/10/2021, 7:12 PM
    hello guys, I am new to SupaBase and I have been fiddling with it for about an hour. I plan to use it along with a nodejs project. Now I wish to find the max value in a column but I couldn't find details about it in the documentation, so how can I pull out the max value from a select statement?
    s
    • 2
    • 4
  • t

    Terry

    11/10/2021, 8:14 PM
    I have user Profiles in my app. It's got normal profile info, but I also want users to do a small quiz/survey thing and store that data.
  • t

    Terry

    11/10/2021, 8:15 PM
    I was thinking of storing it in json. When I load
    /profile/
    I fetch the fields and the blob of json, and template thatt back out as a quiz. Does that sound like a sensible thing to do?
    s
    • 2
    • 3
  • s

    silentworks

    11/10/2021, 9:34 PM
    Where to store quiz survey data
  • m

    magicbyt3

    11/10/2021, 9:53 PM
    Hey all, I am curious about this: RLS is not working for realtime publications - does that mean any table I enable realtime on can be CRUD operated by any authenticated user? So if I enable realtime just to listen for inserts can any authenticated user delete or update my leaderboard or how would that work?
  • s

    Scott P

    11/10/2021, 10:04 PM
    RLS doesn't work with realtime yet, but it's something the team are working to resolve. Subscriptions are read-only and don't enable changing of the data. Requests to CUD data still need to be done through the REST endpoint (which is what the client libraries use, or via any traditional SQL-based approach). RLS will apply to these methods.
  • m

    magicbyt3

    11/10/2021, 10:04 PM
    great news! thank you. πŸ™‚
  • v

    VuNguyen

    11/11/2021, 9:52 AM
    have anyone used supabase in react native? i just wonder if i can login with providers like google or facebook
  • u

    -vi

    11/11/2021, 9:55 AM
    Yes, from what I understood you can do that.
  • v

    VuNguyen

    11/11/2021, 9:55 AM
    i mean, will it open a new browser to do that?
  • u

    -vi

    11/11/2021, 9:56 AM

    https://www.youtube.com/watch?v=EbV746pWDasβ–Ύ

  • u

    -vi

    11/11/2021, 9:57 AM
    Probably yes, as that is how it usually works in general.
  • v

    VuNguyen

    11/11/2021, 9:57 AM
    yea i just wonder if it works on react native
  • v

    VuNguyen

    11/11/2021, 9:57 AM
    ive used it on react before
  • v

    VuNguyen

    11/11/2021, 9:57 AM
    thanks, ill give it a try
  • u

    -vi

    11/11/2021, 9:58 AM
    You're welcome! πŸ™‚
  • m

    Melon Musk

    11/11/2021, 10:20 AM
    Can someone show me how we can connect typeorm with supabase
  • m

    Melon Musk

    11/11/2021, 10:20 AM
    Or have some example code
1...131132133...392Latest