Custom session token
Hey, I somehow need to issue a new token instead of using google/disc/email auth, is there a way to do that somehow? I couldnt find anything in the docs for some reason
14 Replies
Hi @fustuk.. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the provided knowledge sources, Wasp currently supports email/password, Google, and GitHub authentication methods. There isn't any direct information available about issuing a new token instead of using these authentication methods.
However, Wasp does use a
Session
entity to store the user's session information, which is used to keep the user logged in between page refreshes. This entity includes a unique identifier (id
), an expiration date (expiresAt
), and a foreign key to the Auth
entity (userId
). This suggests that it might be possible to create a custom session, but the specifics of how to do this are not provided in the knowledge sources.
For more detailed information or assistance, you might want to check out the Wasp Discord community (https://discord.com/channels/686873244791210014/1216112386335969372) or the Wasp GitHub issues (https://github.com/wasp-lang/wasp/issues/387).
Here is the Session
entity for reference:
Please note that the code you provided is not part of the knowledge sources, so I can't provide specific guidance on it.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @fustuk., I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?cries in spanish
@Wasp Team help lads 😭
I'm not a lad :laughboi: But I'm sure others will jump in asap. :be:
sorry I summoned you here, was intended for the tech lads only 😄
@miho Can you please guide me on where to read in the docs?
I saw that the cookie/bearer whatever it is, comes from Session but we dont have a model for it in prisma
You can access the
Session
entity directly if you need to via imports from @prisma/client
Some background on the Session
entity: https://wasp-lang.dev/docs/auth/entities#entities-explained[ Server!] SyntaxError: The requested module '@prisma/client' does not provide an export named 'Session'
I get an error when trying to import it tho
- Are you using Wasp Auth?
- Did you run
wasp db migrate-dev
?Wohooo @miho, you just became a Waspeteer level 37!
My bad, that's a type 🤦♂️
Try this:
import { prisma } from 'wasp/server'
and then prisma.session.find ...
thanks but I still get some weird errors :/
But my user is in the auth table
You are now hitting into Wasp internals being set up a certain way. The
userId
in the Session
table is actually Auth.id
and not a User.id
🙂
This is what we inject into the Prisma file:
Thank you! I guess you guys missnamed it or something ?
regardless its working now :be:
Thank you! I guess you guys missnamed it or something ?Lucia required the field to be named
userId
, as I said you hit into Wasp internals which we don't really document 🙂gotcha