nextauthjs / next-auth

Authentication for the Web.
https://authjs.dev
ISC License
23.42k stars 3.22k forks source link

Error when login using Google with Sequelize ORM #7536

Open Soso966 opened 1 year ago

Soso966 commented 1 year ago

Adapter type

@next-auth/sequelize-adapter

Environment

System: OS: Linux 5.15 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish) CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz Memory: 2.05 GB / 7.66 GB Container: Yes Shell: 5.8.1 - /usr/bin/zsh Binaries: Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.0/bin/yarn npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm

npmPackages: @next-auth/sequelize-adapter: ^1.0.8 => 1.0.8

Reproduction URL

localhost

Describe the issue

Okay, my issue as follows: I tried to connect my models from Next auth with my models on the backend server.

When I login via Google Provider, it returns my data with email_verified in {account,profile} objects, image

and when passing it to the adapter it shows on CreateUser

image

image

The User model expects the email_verified value to be returned, but it returns null, instead of true/false. image

How to reproduce

I wrote it above

adapter: SequelizeAdapter(sequelize,{
      models:{
        User: sequelize.define("users",{
          ...models.User,
          emailVerified: {
            type: DataTypes.BOOLEAN,
            allowNull: false,
            defaultValue: true,
            field: 'email_verified'
          },
          email_verified: {
            type: DataTypes.BOOLEAN,
            allowNull: false,
            defaultValue: true,
            field: 'email_verified'
          }
        })
        ,
        },

Expected behavior

It should sync the models and their columns

mp3por commented 10 months ago

You should explicitly call sync as per documentation. https://authjs.dev/reference/adapter/sequelize#synchronize