Aniq javed
Aniq javed4w ago

How to check user session

Hi, I am having issue with the signIn as the convex automatically signs in after sign up (using password provider). My main question is that how can I check if the user session is available.
7 Replies
Convex Bot
Convex Bot4w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Aniq javed
Aniq javedOP4w ago
Main aim is to handle sign up functionality without signing in automatically.
erquhart
erquhart4w ago
Auth.js doesn't actually have a dedicated signUp function, that's the root issue here. Can you share more about your use case and what you're trying to accomplish? Maybe there's a creative solution.
Aniq javed
Aniq javedOP4w ago
I have a Sign Up page and once I sign up the functionality I want is that user should not be authenticated unless I Sign In. This is how I am implementing it currrently. Wanted to have a more cleaner version for it. const response = await signIn('password', formData); if (response.signingIn === true) { await signOut(); toast.success('Account created successfully'); router.push('/login'); }
erquhart
erquhart4w ago
Not seeing a way to do this outside of customizing how Auth.js works or doing what you're doing currently
erquhart
erquhart4w ago
Hmm actually looking here you might be able to make it work: https://labs.convex.dev/auth/api_reference/providers/Password
providers/Password - Convex Auth
Authentication library for your Convex backend
erquhart
erquhart4w ago
If you made your own copy of the Password provider: https://github.com/get-convex/convex-auth/blob/main/src/providers/Password.ts#L115 The authorize function behaves differently based on the flow (signup, signin, etc) - I'm wondering if for the sign in flow you can: - create the account as it currently does - return false or something, or even throw a specific expected error that you can catch on the client - handle the outcome in the client ("account created" message, etc) So basically you'd copy/paste the provider from that file I linked into your own project and use it as is, but you'd customize the portion of the authorize function that handles flow === 'signUp' Again, I have not tried this, but it's worth a shot if you need the functionality

Did you find this page helpful?