[SOLVED] Supabase: Prevent non-registered users from using Magic Link Login

  • building_stuff-1296119414558822520

    Janis

    5 months ago

    I am using the /auth/v1/magiclink endpoint to allow users to login. However, the endpoint also allows non-registered users to create an account via the login route. I tried adding a shouldCreateUser attribute to the body object but that does not work.

    Does anyone have an idea how to restrict usage of the login endpoint to only registered users?
    1296119414957019197-
  • needtheanswers-1296129878487203840

    needtheanswers

    5 months ago

    I don´t use Supabase but maybe I would try to query all users based on the input (email) first and if the result doesn´t equal null I would then call the endpoint
  • needtheanswers-1296130624314413097

    needtheanswers

    5 months ago

    but I´m sure that someone has a better solution
  • martinf4630-1296165667178811525

    MartinF

    5 months ago

    I think shouldCreateUser should be a querry param and not it the body
  • tomthebigtree-1296180390817693808

    Tom Ireland

    5 months ago

    You’ll need to use otp instead of magiclink as the last path and use create_user as the key in the body and set to false. Ask me how I know. 😂
  • Gifted to me from the Supabase community: https://github.com/supabase/auth?tab=readme-ov-file#post-otp
  • tomthebigtree-1296180946902450237

    Tom Ireland

    5 months ago

    I recall trying create_user with magiclink and it not working but I could be wrong.
    👍1
  • building_stuff-1296861036397465672

    Janis

    5 months ago

    @Tom Ireland Thank you so much for your help, that worked! I tried the otp path before but used the wrong key in the body. Ahh - that's really an annoying part of Supabase that sometimes the correct answer is hidden somewhere on Github. But thank you so much - seems like you have a bit of a story there 😉
  • building_stuff-1296861292065329152

    Janis

    5 months ago

    [SOLVED ]Supabase: Prevent non-registered users from using Magic Link Login
  • [SOLVED] Supabase: Prevent non-registered users from using Magic Link Login
  • tomthebigtree-1296863494901202995

    Tom Ireland

    5 months ago

    Ah, great news, @Janis ! Thanks for letting me know. Yeah, Supabase info can be a bit challenging to find.

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.