Getting drizzle working with next-auth

Has anyone gotten drizzle working with next-auth? Here's the implementation that I've been using: https://github.com/c-karaolis/drizzle-next-auth-adapter-postgres/blob/main/src/lib/drizzle-next-auth-postgres-adapter.ts From what I can see I have all of my callback urls set up correctly, all environment vars that I need, and nothing else that is barring it from working that I can remember from previous times of setting it up. Maybe I'm missing something obvious here, but I'm really lost as to what is going on. I keep running into this error:
[next-auth][error][adapter_error_getUserByAccount]
https://next-auth.js.org/errors#adapter_error_getuserbyaccount Cannot read properties of undefined (reading 'users') {
message: "Cannot read properties of undefined (reading 'users')",
stack: "TypeError: Cannot read properties of undefined (reading 'users')\n" +
' at getUserByAccount (webpack-internal:///(sc_server)/./src/lib/drizzle-next-auth-postgres-adapter.ts:48:30)\n' +
' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)',
name: 'TypeError'
}
[next-auth][error][OAUTH_CALLBACK_HANDLER_ERROR]
https://next-auth.js.org/errors#oauth_callback_handler_error Cannot read properties of undefined (reading 'users') TypeError: Cannot read properties of undefined (reading 'users')
at getUserByAccount (webpack-internal:///(sc_server)/./src/lib/drizzle-next-auth-postgres-adapter.ts:48:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
name: 'GetUserByAccountError',
code: undefined
}

- ┌ GET /api/auth/callback/github?code=50c5bc4bdc41e92f635b&state=pyudVQcppttAMcVmtAaOT15_0Afb8bR8C_1lnsVpPgQ 302 in 497ms

└──── GET https://api.github.com/user/emails 403 in 135ms (cache: MISS)
[next-auth][error][adapter_error_getUserByAccount]
https://next-auth.js.org/errors#adapter_error_getuserbyaccount Cannot read properties of undefined (reading 'users') {
message: "Cannot read properties of undefined (reading 'users')",
stack: "TypeError: Cannot read properties of undefined (reading 'users')\n" +
' at getUserByAccount (webpack-internal:///(sc_server)/./src/lib/drizzle-next-auth-postgres-adapter.ts:48:30)\n' +
' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)',
name: 'TypeError'
}
[next-auth][error][OAUTH_CALLBACK_HANDLER_ERROR]
https://next-auth.js.org/errors#oauth_callback_handler_error Cannot read properties of undefined (reading 'users') TypeError: Cannot read properties of undefined (reading 'users')
at getUserByAccount (webpack-internal:///(sc_server)/./src/lib/drizzle-next-auth-postgres-adapter.ts:48:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
name: 'GetUserByAccountError',
code: undefined
}

- ┌ GET /api/auth/callback/github?code=50c5bc4bdc41e92f635b&state=pyudVQcppttAMcVmtAaOT15_0Afb8bR8C_1lnsVpPgQ 302 in 497ms

└──── GET https://api.github.com/user/emails 403 in 135ms (cache: MISS)
GitHub
drizzle-next-auth-adapter-postgres/src/lib/drizzle-next-auth-postgr...
A custom drizzle orm adapter for NextAuth.js. Contribute to c-karaolis/drizzle-next-auth-adapter-postgres development by creating an account on GitHub.
2 Replies
Sturlen
Sturlen2y ago
there is an implementation for this in the create-t3-app repo which does this: https://github.com/t3-oss/create-t3-app/blob/drizzle/cli/template/extras/src/server/auth/with-drizzle.ts
GitHub
create-t3-app/cli/template/extras/src/server/auth/with-drizzle.ts a...
The best way to start a full-stack, typesafe Next.js app - create-t3-app/cli/template/extras/src/server/auth/with-drizzle.ts at drizzle · t3-oss/create-t3-app
Kyle
KyleOP2y ago
work, that looks nice I'm running into issues with the getServerAuthSession wrapper that they provided, odd
Want results from more Discord servers?
Add your server