T3 & Mongoose

I have an existing Discord bot which uses Mongoose to keep track of who uses it and store values relating to their account If I wanted to make a T3 app for the discord bot, how can I integrate my existing Mongoose database with NextAuth to allow users to login on the site @Josh
Solution:
Callbacks | NextAuth.js
Callbacks are asynchronous functions you can use to control what happens when an action is performed.
Jump to solution
20 Replies
sonor
sonor10mo ago
Essentialy, I want to add extra middleware to the DiscordProvider to compare with my MongoDB database, to check if the user exists, and if so attach an ID from their Mongoose record to their NextAuth session
Josh
Josh10mo ago
ah okay your looking for this
Solution
Josh
Josh10mo ago
Callbacks | NextAuth.js
Callbacks are asynchronous functions you can use to control what happens when an action is performed.
sonor
sonor10mo ago
oh a callback on signin seems like yeah thank you
Josh
Josh10mo ago
yessir you'll still use that adapter I linked eh actually I guess I can see why you're just using jwts if you're strictly using discord and already have their keys
sonor
sonor10mo ago
im a bit confused with that, would i better to just use JWT since im not already using prisma etc i didnt see the point in having a seperate DB just for sessions, but i still find nextauth a little confusing so maybe im thinking of it the complete wrong way
Josh
Josh10mo ago
the problem is jwts won't be persistent
sonor
sonor10mo ago
and the DB way would be?
Josh
Josh10mo ago
yeah
sonor
sonor10mo ago
ah okay
Josh
Josh10mo ago
cause you'd have the session in the db
sonor
sonor10mo ago
yeah gotcha hmm i see okay ill figure something out thank you for the help
Josh
Josh10mo ago
i actually really recommend building your own adapter tbh, it's pretty easy to just go rip out the core of the adapter in the one I linked then just modify it how you need to that's what I did with my boiler plate and it works like a charm, and makes the whole thing wayyyyyy less of a black box
sonor
sonor10mo ago
ah okay thats a good idea aswell might do that tbh
Josh
Josh10mo ago
GitHub
GitHub - GentikSolm/t3-app-dir: t3 app dir boilerplate
t3 app dir boilerplate. Contribute to GentikSolm/t3-app-dir development by creating an account on GitHub.
Want results from more Discord servers?
Add your server