From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Prisma user-related models - Next.js Tutorial
From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch
Prisma user-related models
So now we're going to add our Prisma models for authentication. There's about four models we need to add. Now this documentation page at authjs.dev, so slash getting started slash adapters slash Prisma. It has this section here where you can choose the database in our case Postgres, and it shows us the models that we need. Now we need to change some stuff up here. There's some fields we need to add. There's some annotations we need to add and change. So I'm going to copy each one one by one, and then we'll go through it. Now, this Auth.js, basically NextAuth was originally created just for Next.js, but it's broadened to other frameworks. So that's where this Auth.js comes in. So a lot of the documentation that we're going to use is from Auth.js.dev. So let's grab the user model and copy it. And let's go into Prisma, schema.prisma. Actually, we can get rid of these comments. There's no need for those. And then we're going to paste this under our product model. And I'm just going to go…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Section intro2m 57s
-
(Locked)
Prisma user-related models9m 45s
-
(Locked)
Seed user data7m
-
(Locked)
NextAuth setup17m 31s
-
(Locked)
NextAuth catch all API route4m 12s
-
(Locked)
Sign-in and sign-out server actions8m 27s
-
(Locked)
Auth layout and sign-in page6m 58s
-
(Locked)
Credentials sign-in form6m 39s
-
(Locked)
Hook up sign-in form9m 28s
-
(Locked)
Callback URL redirect4m 26s
-
(Locked)
User button and sign-out11m 48s
-
(Locked)
Signup Zod schema and action8m 15s
-
(Locked)
Sign-up page and form7m 35s
-
(Locked)
Sign-up error handling12m 40s
-
(Locked)
Customize token with JWT callback8m 19s
-
(Locked)
-
-
-
-
-
-
-
-
-
-
-
-
-