我正在使用 Nextjs 12、NextAuth(Google)、Prisma(MySQL) 构建一个博客平台。当用户首次注册我的平台时,NextAuth 会自动将用户的 google 电子邮件地址和 google 名称保存到我的数据库中。我想让用户在第一次注册时更改他们的昵称。
我如何知道用户是否正在注册或登录?目前在 NextAuth 中,您单击signup()按钮即可进行注册和登录。
我正在使用 Next.js Prisma NextAuth。我需要访问我的一个表的 prisma 生成类型,以便我可以从中扩展我的 NextAuth 类型。
我的问题是,如何访问用户模型的类型?
model User {
id String @id @default(cuid())
name String
nickname String? @unique
email String @unique
emailVerified DateTime?
image String? @db.VarChar(500)
title String?
description String? @db.VarChar(500)
accounts Account[]
sessions Session[]
VisitedRestaurants VisitedRestaurants[]
Reviews Reviews[]
ReviewImages ReviewImages[]
ReviewLikes ReviewLikes[]
ReviewComments ReviewComments[]
}
Run Code Online (Sandbox Code Playgroud) class Circle {
constructor() {
this.width = 2;
this.height = 3;
}
static area() {
return this.width * this.height
}
}
console.log(Circle.area()) // NaN
Run Code Online (Sandbox Code Playgroud)
我了解到 Class 的静态方法将 this 绑定到 Class 本身,而不是 Instance 的新对象。所以我期望 Cicle.area() 返回 6,它来自 (2 * 3)。但实际结果返回 NaN。我找不到原因。
next-auth ×2
prisma ×2
ecmascript-6 ×1
javascript ×1
next.js ×1
react-native ×1
this ×1
typescript ×1