NextAuthでログインエラー
1分目次
とりあえずエラーメッセージ。
https://next-auth.js.org/errors#oauth_callback_handler_error PrismaClientValidationError: Invalid `prisma.user.create()` invocation:
{
data: {
name: 'hoge',
email: 'fuga',
image: '',
~~~~~
emailVerified: null
~~~~~~~~~~~~~
}
}
Unknown arg `image` in data.image for type UserCreateInput. Did you mean `name`? Available args:
type UserCreateInput {
name?: String | Null
email?: String | Null
createdAt?: DateTime
updatedAt?: DateTime
posts?: PostCreateNestedManyWithoutAuthorInput
}
Unknown arg `emailVerified` in data.emailVerified for type UserCreateInput. Did you mean `email`? Available args:
type UserCreateInput {
name?: String | Null
email?: String | Null
createdAt?: DateTime
updatedAt?: DateTime
posts?: PostCreateNestedManyWithoutAuthorInput
}
Try signing with a different account. って表示される
多分下記と同じ。 https://github.com/nextauthjs/next-auth/issues/1106
解決方法
僕の場合は Prisma の model 定義に image と email_verified が足りなかった
model User {
id Int @default(autoincrement()) @id
name String?
email String? @unique
+ emailVerified DateTime? @map(name: "email_verified")
+ image String?
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
posts Post[]
@@map(name: "users")
}