nextauthjs / nextauthjs/next-auth

Extending models

Open
#4,029 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

adapters sequelize triage
Dominant language
TypeScript
Stars
28.4k
Forks
4k
PR merge metrics
No merged PRs in 30d

Description

Question 💬

I'm trying to alter my user schema to take in a couple more details.

Following the docs here.

The problem is when I even try and use the provided models it still breaks with the error GetUserByEmailError: column "emailVerified" does not exist doesn't make sense since I can see it exists and there are even users.

I'm using the email provider but I don't think I have altered anything that should cause it to break. 🤔

I'm probably missing something (or my coffee isn't strong enough).

NextAuth(req, res, {
    adapter: SequelizeAdapter(sequelize, {
      synchronize: true,
      models: {
        User: sequelize.define('user', {
          ...models.User,
        }),
      },
    }),

    providers: [
      EmailProvider({
...
How to reproduce ☕️
// importing the models
import SequelizeAdapter, { models } from '@next-auth/sequelize-adapter';

// then setting up the adapter to prepare to extend the user model
 adapter: SequelizeAdapter(sequelize, {
      synchronize: true,
      models: {
        User: sequelize.define('user', {
          ...models.User,
        }),
      },
    }),
Contributing 🙌🏽

Yes, I am willing to help answer this question in a PR

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the SequelizeAdapter configuration and the custom models.User definition shown in the issue, then reproduce the email-provider GetUserByEmailError. Compare the generated or queried column name with the documented custom-model setup; done means extending the User model no longer produces the missing emailVerified error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs, nodejs, typescript
Domain
authentication, backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.