Question about next auth.
Hey all, The stack and full stack development in javascript in general is new for me.
I finding my way around while using the documentation. But I was wondering what the best way/ implementation should be to use next auth to call a query from another API. Old API that is still in use for verification. I can make this call with the correct credentials .
Afterwards i want to check in the same function for the email and password via a trpc query in a table in my database and return the result (unique user with that email and password) as my user in the session.
But i'm kinda stuck on the big picture here i guess.
Thanks in advance.
And if this is not appropriate to ask in the discord. Feel free to delete this.
10 Replies
`
I guess this won't work (pseudocode) ?
The thing you explicitly outlined in the pseudocode would not work. You imported a specific router and tried to access a procedure on it. When tRPC initializes does a lot of things, constructs the context and other configurations ( especially if you have built it using create-t3-app ) which it then uses in the other underlying routers which you then compose in the appRouter.
What you want to do is achievable, but you will have to import the appRouter and create a new instance by calling
.createCaller({})
on it. It will give you a new tRPC router which you can use to authorize the user.
Your code might look something like this:
you can also reffer to the official documentation for more details:
https://trpc.io/docs/server/server-side-calls
Server Side Calls | tRPC
You may need to call your procedure(s) directly from the same server they're hosted in, router.createCaller() can be used to achieve this.
Hmm. Still stuck on it. But thanks for the info!
what seems to not work
I think i might be confused on how to interact with the session from there. Should it just work when I return an user? Or what is the next step? If you are willing I would love to share some more details in private in about an hour
sure, feel free to pm me
yo is credentails provider like a login form?
just wondering
never used credentials provider only other providers like google , discord etc
yes
sick