shadow_aya
CCConvex Community
•Created by shadow_aya on 4/30/2024 in #support-community
Convex & Lucia might be depricated on v3
Unfortunate news, just I was about to celebrate that Convex & Lucia work well together and I ran into a roadblock.
Lucia's API got changed in version 3, the issue is getting a session
- convex-lucia-auth-demo
convex/withAuth.ts:117
- new lucia API github discussion
the new Lucia
class has no getSession
function, which allowed you to only read the session
notice the comment above in the v2 demo repo:
with seemingly only Lucia#validateSession
left, I think it's no longer possible to use in queries at all. can someone else have a look and confirm? if you wish, I can quickly share my v3 repo where I found this out (but there isn't really much more to it)
Thanks :FallenQiqi:8 replies
CCConvex Community
•Created by shadow_aya on 12/6/2023 in #support-community
Create user on Clerk registration
I would like to create an entry in my
users
table when Clerk auth finishes (for new users).
I created a bumpUser
function:
My intent was to trigger it via Clerk middleware, but I immediately realized that might not be a good idea:
middleware.ts
- afterAuth
fires multiple times. this is probably intentional on Clerk's side, but it's kind of stupid to be honest, they even combined the flow for all users who pass public pages and protected pages for those who are logged in. so far Convex queued the mutations well and didn't create duplicate users, so I assume I don't have to worry about this?
- I can imagine the function blowing up even when two users request at the same time and token is mistakenly set. yes yes, this is very unlikely, but it looks like it could happen. I'm surprised the http client methods don't have an options argument where I could explicitly declare this token. you can take this part as a feature request, unless someone clarifies why that's not necessary
should I instead somehow call the mutation on the client? do I make some adjustment? I am new to Clerk, and I've never done auth with Convex either. these abstractions are very simple, but can also be broken in a simple way.
last thing I thought of while typing this - how's the type safety between Clerk and Convex user objects? (actually this might be a dumb question since Convex must be formatting the user object in its own way when verifying and typing it, unless there's also some missing keys for the various auth methods Convex can be used with)
Thanks :PatTao:
update
looking into Clerk's webhooks instead, but I'm still interested about the token setting2 replies
CCConvex Community
•Created by shadow_aya on 11/11/2023 in #show-and-tell
"'internal' authentication" for a HTTP client
Personally, almost all of my Convex functions are meant to be used backend-to-db (might be questionable design but let's forget that for a minute). In finding https://discord.com/channels/1019350475847499849/1103697990331416587 and realizing that, in theory, anyone can call my session & rate limiting functions, I first panicked, and then came with an acceptable solution.
ConvexHttpClientAsServer
for context
DB_TOKEN
on Convex matches CONVEX_DB_TOKEN
on server
usage
findBySid
method
this is kind of a madness but it works - no need to dotenv anywhere else, and it's still typesafe.
note: to validate the function's arguments - in case 'dbToken' doesn't exist, args will be never
So yeah, if anyone wants to use this, you may :HuTaoThumbsUp:3 replies
CCConvex Community
•Created by shadow_aya on 10/21/2023 in #support-community
Query typing malfunction
session.Store#destroy
method
siteSessions#findBySid
Convex function
siteSessions table schema
15 replies