NextAuth Credentials Provider DB Sessions
Unanswered
West African Lion posted this in #help-forum
West African LionOP
I know that NextAuth does not push Sessions to the Database when using the Credentials Provider, even when you specifically tell it to do so. So what would be the simplest way to do this manually? It should 1. Write a new User Session to the Database with the JWT Token and all of the Details 2. Delete a Session when a User logs out and 3. Delete a session after the maxAge value is reached.
1 Reply
You could use the
jwt callback (https://next-auth.js.org/configuration/callbacks#sign-in-callback) to create an entry in the database with all the info, for the sign out you could send the user to a page that handles the deletion of the entry and redirects the user to where ever you want them to be after signing out and for the automatic deletion, you could use cron jobs in your database.