Next Auth Credentials Provider - Ultimate Guide

Next Auth Credentials Provider - Ultimate Guide

Brett Westwood - Software Engineer

10 месяцев назад

46,775 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Harsingh Sekhon
Harsingh Sekhon - 27.11.2023 04:32

Thank you so much Brett!

Ответить
Patrick mbugua
Patrick mbugua - 26.11.2023 12:01

I really sort this type of content,prisma,custom login page ,credentials,next-auth so far this is the best tutorial for that

Ответить
Jelly fish
Jelly fish - 23.11.2023 19:28

you should have used typescript

Ответить
fijfncifjrjfkfor
fijfncifjrjfkfor - 20.11.2023 19:24

Thank you. The official next auth guide for credentials provider is broken and this helped out

Ответить
Shivpratik Habib
Shivpratik Habib - 18.11.2023 16:34

Thank you for the detailed tutorial! Can you also make a video on "Remember Me" functionality with Next Auth?

Ответить
Sleepawalker White
Sleepawalker White - 14.11.2023 14:42

Dude, you're the first one who normally explained how to work with the ugly "NextAuth" along with "login/password" without fуcking authentication via a social network.

Thank you.

Ответить
Sky Media
Sky Media - 10.11.2023 10:14

why you didnt add the middleware?

Ответить
Ameliance SkyMusic
Ameliance SkyMusic - 09.11.2023 14:10

I've got an error, does anyone have any solutions?:

PrismaClientInitializationError:
Invalid `prisma.user.findUnique()` invocation:

Error in connector: Error creating a database connection. (Kind: An error occurred during DNS resolution: proto error: io error: A socket operation was attempted to an unreachable network. (os error 10051), labels: {})

Ответить
Temo S
Temo S - 03.11.2023 15:11

Hey, is using NextResponse.json mandatory here? Why don't we just use Response global object instead ?

Ответить
Robert
Robert - 01.11.2023 23:12

If I have a express.js backend where I have setup a MySQL database with Sequelize, and i have a next.js frontend, how could I make it work with NextAuth?

Ответить
Julian Hernandez
Julian Hernandez - 30.10.2023 00:01

How do I access the session a server component (the equivalent of useSession for server side)?

Ответить
Spektree
Spektree - 25.10.2023 22:09

Bro is majestic

Ответить
Alireza
Alireza - 24.10.2023 05:59

tnx, great tutorial, my question is how bcrypt can unhash hashedPassword without any salt ? (how this working?)

Ответить
Aleksandr Petrov
Aleksandr Petrov - 22.10.2023 09:59

After you've wrapped everything in SessionProvider, will you actually get to register page? I'm being redirected to login page in my app. Now I think maybe I need to create (protected) and (public) folders after which wrap children in layout.tsx inside (protected) folder. Not sure if it's best practice but it might work

Ответить
看到我的小黑了吗
看到我的小黑了吗 - 20.10.2023 08:55

So cool. The tutorials in the Chinese community are so old that I had to come here for help

Ответить
Liam R. | MnkyArts
Liam R. | MnkyArts - 19.10.2023 18:56

Great tutorial but the zoom is kind of annoying

Ответить
Shane Murphy
Shane Murphy - 18.10.2023 17:18

Brett keeps deleting my comment so I'll keep writing it. If you're here in believe that this is a solid tutorial on Next auth, this ain't!!! Brett solution is utter rubbish!! I've recreated he's solution only to find zero authentication happening, users can access the dashboard page by localhost:300/dashboard WITHOUT NEVER logging in!!! users can login with any email or password without NEVER registering that user. He's solution is a complete joke. Don't waste your time here I like did, there is ZERO authentication happening with he's tutorial!!!

Ответить
Shane Murphy
Shane Murphy - 17.10.2023 19:32

No Sign out functionality!!! therefore what is the point!

Ответить
Tamagas said
Tamagas said - 12.10.2023 17:35

Great tutorial than you, but why username instead of email? How do you handle if you want email login and for example google and facebook? Thank you

Ответить
Mubashir Waheed
Mubashir Waheed - 09.10.2023 08:36

Hello Brett is it possible to redirect the user to the `onboarding` page after signup and the user doesn't have to login when using credential provider?

Ответить
Isosceles Kramer
Isosceles Kramer - 09.10.2023 06:54

The mixing of camelCase and snake_case keys in that Prisma schema is painful to see. I know libraries can have their own conventions (even if they are wrong by using snake_case in JS), but that accounts model has both cases in the same table. Very very messy. Please use @map() directive to normalize so improper snake_case fields get converted to the proper camelCase names, so in code you can use the proper camelCase convention.

Ответить
blake matthes
blake matthes - 07.10.2023 23:57

i followed your guide to a t and love it i dont really want to learn type script yet..... but i when i try to sign in i have to do it twice in order to get signed in.. did i miss something in this one or your other jwt video ? no errors just have to sign in twice.

incase someone else runs across this i spent longer on this and found my issue was i was redirecting the same time i was signing in i put await in front of sign in and it solved my issue

Ответить
Arxci
Arxci - 07.10.2023 01:42

Im going to lose my mind hearing you say Prisma wrong

Ответить
CodeHassanX
CodeHassanX - 28.09.2023 17:41

Amazing

Ответить
Tony Feferman
Tony Feferman - 21.09.2023 06:17

git repo would be super-helpful with few nuances

Ответить
Gildson Alves
Gildson Alves - 21.09.2023 04:31

Hi, great job!
Some questions...
How about persist token to client and use it in API requests? How to refresh token too and use this solution with a google provider and still use a valid token to make requests, for example?

Ответить
Max Tyshkevich
Max Tyshkevich - 20.09.2023 04:39

I don't understand. How this example use adapter Prisma? Session won't be save in database. We can you next-auth without adapter Prisma, and in authorize () call Prisma.

Ответить
Amir BTCD
Amir BTCD - 15.09.2023 01:32

As `bcrypt` is not available on Edge runtime, how do I need to encrypt passwords?

Ответить
Phipattanachai Rinfong
Phipattanachai Rinfong - 11.09.2023 19:15

Where is the register code? Why can't I find it?

Ответить
Moon Moon
Moon Moon - 11.09.2023 15:53

use ts ?🤔

Ответить
DEEPAK KUMAR
DEEPAK KUMAR - 11.09.2023 13:02

! important
How to implement role based redirect. eg. for user has "/user" and for admin has "/admin". When I signin successfully then it will automatically redirect.

Ответить
Matei Marian
Matei Marian - 09.09.2023 17:36

Thanks it helped me a lot, when building my Saas.

Ответить
Oleksandr Stepaniuk
Oleksandr Stepaniuk - 07.09.2023 18:05

Дякую, саме те що шукав!

Ответить
Sulav Baral
Sulav Baral - 07.09.2023 15:31

how shall we structure the database if we need both oauth and credential login

Ответить
Gabriel
Gabriel - 05.09.2023 19:50

I tried to implement this but it doesn't create a session-token in the browser. It only works with the /api/auth/signIn default page but with /my-login it won't create that session. I even have pages: {
signIn: '/my-login',
},

Ответить
Aymane
Aymane - 01.09.2023 16:12

is it possible to implement this using server actions?

Ответить
Razac_zr
Razac_zr - 01.09.2023 06:50

Nice video

Ответить
merakli
merakli - 27.08.2023 08:17

Thank you for the great tutorial. Keep up the good work!

Ответить
Mike
Mike - 24.08.2023 01:27

This almost worked until I got to login. it doesn't print the session to the console or the dashboard.

Ответить
thomas frimpong
thomas frimpong - 23.08.2023 14:35

God bless you for this work. i expected logout any way.

Ответить
Ayman Azougar
Ayman Azougar - 22.08.2023 16:40

You did miss a part , if we look at the redirect method that you made after signIn , even if the user provide wronf credentials , it still route him to dashboard

Ответить
Md Kayda Azam
Md Kayda Azam - 22.08.2023 11:56

where are source code brother?

Ответить
Vercality_
Vercality_ - 22.08.2023 03:40

Very good, followed your tutorial and got everything working, subscribed.

Ответить
Olaleye Oyewunmi
Olaleye Oyewunmi - 17.08.2023 21:07

Really love your video… please can you make a video using typescript … I’m having issues passing the session as a props in the rootLayout

Ответить
Jonker Koorts
Jonker Koorts - 16.08.2023 13:29

Is it possible to share the github repo with us? 😃

Ответить
Programmer
Programmer - 14.08.2023 09:34

Does the NextAuth Provide any JWT , your server doesn't send that token though?

Ответить
Md Amir Hossain
Md Amir Hossain - 11.08.2023 07:13

Awesome content. Just right things at the right time. Love it.

Ответить
Jan Pawełdwa
Jan Pawełdwa - 08.08.2023 17:45

You set the session as a required prop on the Provider, but when wrapping the body with it, you never pass that prop. How does that work?

Ответить
arya prima
arya prima - 01.08.2023 15:12

can i try this with sql?, this tutorial is very useful, and i am very happy, after few days studying about credentials

Ответить