Cannot read property 'includes' of undefined in prisma adapter with credentials provider
See original GitHub issueHoping someone can help me. I had success getting the google provider authentication working with a prisma adapter implementation. However, I’m having trouble getting the credentials provider to work, and also had the same error response when trying with email.
I get the following error when using Credentials or email
[next-auth][error][callback_oauth_error] https://next-auth.js.org/errors#callback_oauth_error TypeError: Cannot read property ‘includes’ of undefined at Object.<anonymous> (D:\Web\StoreApp\nextjs-store\node_modules\next-auth\dist\server\lib\oauth\pkce-handler.js:54:32) at Generator.next (<anonymous>) at asyncGeneratorStep (D:\Web\StoreApp\nextjs-store\node_modules\next-auth\dist\server\lib\oauth\pkce-handler.js:32:103) at _next (D:\Web\StoreApp\nextjs-store\node_modules\next-auth\dist\server\lib\oauth\pkce-handler.js:34:194) at D:\Web\StoreApp\nextjs-store\node_modules\next-auth\dist\server\lib\oauth\pkce-handler.js:34:364 at new Promise (<anonymous>) at Object.<anonymous> (D:\Web\StoreApp\nextjs-store\node_modules\next-auth\dist\server\lib\oauth\pkce-handler.js:34:97) at Object.handleCallback (D:\Web\StoreApp\nextjs-store\node_modules\next-auth\dist\server\lib\oauth\pkce-handler.js:41:26) at D:\Web\StoreApp\nextjs-store\node_modules\next-auth\dist\server\index.js:256:32 at Generator.next (<anonymous>) at asyncGeneratorStep (D:\Web\StoreApp\nextjs-store\node_modules\next-auth\dist\server\index.js:52:103) at _next (D:\Web\StoreApp\nextjs-store\node_modules\next-auth\dist\server\index.js:54:194) at runMicrotasks (<anonymous>) at processTicksAndRejections (node:internal/process/task_queues:94:5)
Here is my […nextauth].js
import NextAuth from "next-auth";
import Providers from "next-auth/providers";
import Adapters from "next-auth/adapters";
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
export default NextAuth({
providers: [
Providers.Credentials({
// The name to display on the sign in form (e.g. 'Sign in with...')
name: "Credentials",
// The credentials is used to generate a suitable form on the sign in page.
// You can specify whatever fields you are expecting to be submitted.
// e.g. domain, username, password, 2FA token, etc.
credentials: {
username: { label: "Username", type: "text", placeholder: "jsmith" },
password: { label: "Password", type: "password" },
},
async authorize(credentials) {
// Add logic here to look up the user from the credentials supplied
const user = await prisma.user.findUnique({
where: {
username: credentials.username,
password: credentials.password,
},
});
if (user) {
// Any object returned will be saved in `user` property of the JWT
return user;
} else {
// If you return null or false then the credentials will be rejected
return null;
// You can also Reject this callback with an Error or with a URL:
// throw new Error('error message') // Redirect to error page
// throw '/path/to/redirect' // Redirect to a URL
}
},
}),
],
adapter: Adapters.Prisma.Adapter({ prisma }),
});
I can give provide access to the repo for anyone that’s willing to have a look.
https://github.com/sunrunner4kr-simon/StoreApp
Thanks in advance!
Feedback Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.
- Found the documentation helpful
- Found documentation but was incomplete
- Could not find relevant documentation
- Found the example project helpful
- Did not find the example project helpful
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
🎉 This issue has been resolved in version 4.0.0-next.5 🎉
The release is available on:
Your semantic-release bot 📦🚀
Thank you @balazsorban44 as always!!