DEV Community

Cover image for Authentication with credentials using Next-Auth and MongoDB - Part 2

Authentication with credentials using Next-Auth and MongoDB - Part 2

Mainak Das on July 15, 2021

In the last part, I created the signup, login and route along with the and the connection of frontend to the backend. Also, I created the sign-in l...
Collapse
 
shakvilla profile image
Shakvilla

I have an issue after using this logic. I modified it a little, where a user creates a client but when i login with client details, and try to fetch data of logged in client, I'm unable to fetch data of the current client, i figured I'm not able to implement a logic to allow data fetching for current user, do you think you can help out with the logic, i followed your tuts and implemented authentication and its working, just fetching data and displaying for current logged in user

Collapse
 
dawnind profile image
Mainak Das

Can you atleast post some snippets or source code so that I can understand a bit better !

Collapse
 
deathreboot profile image
Death-reboot

hey can you share Source Code of this

Collapse
 
dawnind profile image
Mainak Das

Here you go:
Authentication with credentials using Next-Auth and MongoDB

Add MongoDB connect url in a .env file as MONGO_URI

Collapse
 
muhrizqiardi profile image
muhrizqiardi

Hey, just wanted to say thank you for writing this article. This helped me a lot for my assignment!

Collapse
 
dawnind profile image
Mainak Das

You're welcome :) glad to help

Collapse
 
nizarfadlan profile image
Nizar Izzuddin Yatim Fadlan

How to multiple role use custom session and jwt?

Collapse
 
regisnut profile image
Regisnut

Hi, how do you handle signup with others data such as tel, adress, city... and also, how do you handle reset/forgot password??
THAnks.

Collapse
 
dawnind profile image
Mainak Das

For signup with other data you've to assign those to the user object before posting it to the database.
You've to implement your own reset or forgot password strategy, for example
Change password

Collapse
 
j0hannr profile image
j0hannr

Thanks for the great tutorial!

I Forked your Project to use it with Prisma instead of MangoDB
github.com/j0hannr/next-auth-crede...
And Updated to NextAuth v4

Collapse
 
richardpickett profile image
Richard Pickett

wheatear = whether

Collapse
 
dawnind profile image
Mainak Das

thanks man :)