Corbi-Wan KenobiC
Convex Communityβ€’12mo agoβ€’
6 replies
Corbi-Wan Kenobi

Convex Auth workflow

I'm converting from Remix/ReactRouter7 and Supabase to TanStack Start and Convex. I have this working in the other app and I'm having trouble knowing what to put where in "TanVex" or "ConStack" πŸ™‚

Step 1 - User puts their email in a form for a Magic Link auth (which I have working on its own), and clicks the button.

Step 2 - I need convex to take the submitted email address, query my "people" table and check if (a) the email exists/is connected to a user and (b) the "can_login" boolean for the user is set to true. Here is how I'm capturing the email address and sending it to the query:
const formData = new FormData(event.currentTarget); const submittedEmail = formData.get("email"); const { data } = useSuspenseQuery(convexQuery(api.personEmails.checkCanLogin, {email_address: submittedEmail}));

I have that happening in the sample login form linked below (between lines 58 and 59). I don't know how to grab and use the submittedEmail in the query I'm working on in the personEmails.checkCanLogin, nor do I know how to return back to the login page that requested it.

Step 3 - If the tests pass, proceed with the magic link process and display a "check your email" message. If the tests fail, show a "that address is not authorized" message.

I was working with the sample login form located here as a template (https://github.com/get-convex/convex-auth-example/blob/main/src/auth/SignInFormEmailLink.tsx). I'm new to both Convex and Tanstack. I haven't figured out how to pass the formData email to the convex query that I've put in a person_emails.ts file. That's where I'm stuck. I'll of course need to return the results.

There are great examples of pulling all rows from a table in the docs. I can't find good examples of accepting, passing, and returning things like this search. I'm guessing its framework specific. I get Remix/RR7 loaders and actions, I'm having trouble bridging the concepts here.
Was this page helpful?