PricingDocsAcademy
Bluesky ...
Fri, Dec 13, 9:05 AM

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

  • /attachments/1296119414558822520/1296119414957019197/image.png

    Janis

    1 month 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?
  • needtheanswers

    1 month 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

    1 month ago

    but I´m sure that someone has a better solution
  • MartinF

    1 month ago

    I think shouldCreateUser should be a querry param and not it the body
  • Tom Ireland

    1 month 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
  • Tom Ireland

    1 month ago

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

    1 month 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 😉
  • Janis

    1 month ago

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

    1 month 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.