Build auth apis with next.js using trcp
Greetings I've been working on trcp for a while and I really like it. I tried to do authentication using next-auth and it was amazing but I had a little problem.
The app I've built is using Next, Prisma, next-auth.
I can easily use next-auth for web authentication, but what I want is to use authentication with is the mobile app (react-native)
What i did is :
In trcp context I checked if the user has a session using next-auth getSession, if the user has no session I check the request headers for a token and I decode and verify this token
And in case the user has no session and no token I return null
Then in the trcp middleware I checked if the user exists or not
Note: I build login api with trcp that return a token
What do you think of this solution is it correct or not?
and is there any better ideas to do this?
The app I've built is using Next, Prisma, next-auth.
I can easily use next-auth for web authentication, but what I want is to use authentication with is the mobile app (react-native)
What i did is :
In trcp context I checked if the user has a session using next-auth getSession, if the user has no session I check the request headers for a token and I decode and verify this token
And in case the user has no session and no token I return null
Then in the trcp middleware I checked if the user exists or not
Note: I build login api with trcp that return a token
What do you think of this solution is it correct or not?
and is there any better ideas to do this?