Storing jwt token with nuxt-auth-utils
Does nuxt-auth-utils support storing normal jwt tokens inside the session object?
2 Replies
Hi @LordGhandi. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The knowledge sources indicate that nuxt-auth-utils manages session data using secured and sealed cookies, and you can store arbitrary data inside the session object, such as user information. For example, in the login API route, the session is set with a user object:
While the documentation and examples show storing user objects, they do not explicitly mention storing a raw JWT token. However, since the session object can hold arbitrary data, you should be able to store a JWT token as a property (e.g.,
token
) within the session object:
This approach aligns with the way session data is managed in nuxt-auth-utils, but the documentation does not explicitly confirm or deny support for storing raw JWT tokens. Therefore, while it appears possible, please note that this is inferred from the general usage of the session object and not directly stated in the documentation Sessions and Authentication.
If you need to access the token on the client side, you can retrieve it from the session using the useUserSession
composable:
In summary: nuxt-auth-utils appears to support storing a JWT token inside the session object, but this is not explicitly documented. Use with caution and test to ensure it meets your requirements.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@358749735323959308> Kapa.ai is still learning and improving, please let me know how I did by reacting below.