title: Why is Id only getting saved in database and no other data?
body: <p>I am adding authentication to my React app using Passport, sequelize and MySql, but data is not getting saved into mySql database, only Id and null fields.
  I'm trying to implement the local strategy.</p>
  
  <p>When trying the post route in postman, I get a 200 response, with the email, and hashed password. However, ID field shows as null. When checking mysql database I can see a new row added with the ID, but username and password are empty. Is there anything I'm missing here?</p>
  
  <p>Passport Strategy file</p>
  
  <pre><code>const Strategy = require('passport-local').Strategy;
  const User = require('../models').User;
  const bcrypt = require('bcryptjs');
  const salt = bcrypt.genSaltSync(10);
  
  const SignupStrategy = new Strategy({ passReqToCallback: true, 
  usernameField: "email", passwordField: "password" }, function (req, email, 
  password, done) {
  
  User.findOne({
      where: {
          email: email
      }
  })
      .then((user, error) =&gt; {
          if (error)
          return done(null, user);
      })
  const encryptedPassword = bcrypt.hashSync(password, salt);
  let newUser = new User({
      email,
      password: encryptedPassword
  })
  User.create(newUser)
      .then((user) =&gt; {
          newUser
          ;
          done(null, newUser)
      })
      .catch((error) =&gt; {
          done(error, null)
      })    
  });
  
  module.exports = SignupStrategy;
  </code></pre>
  
  <p>User model</p>
  
  <pre><code> module.exports = function (sequelize, DataTypes) {
   var User = sequelize.define("User", {
   username: {
    type: DataTypes.STRING,
    // allowNull: false,
    unique: true,
    validate: {
      len: [1]
    }
   },
   email: {
      type: DataTypes.STRING,
    // allowNull: false,
      unique: true,
      validate: {
      isEmail: true
      }
    },
   password: {
    type: DataTypes.STRING,
    // allowNull: false
    }
    });
  
    return User;
   };
  </code></pre>
  
  <p>Route</p>
  
  <pre><code>  const express = require('express');
    const router = express.Router();
    const passport = require('../passport');
  
    router.post('/signup', (req, res, next) =&gt; {
  
        passport.authenticate('local-signup', function(error, user, info) {
            if (error) {
                res.status(500).json({
                    message: 'Ooops, something happened',
                    error: error.message || 'Internal server error'
                });
            }
  
            res.json({user})
        })(req, res, next)
    });
  
    router.post('/signin', function(req, res, next) {
        res.send('respond with a resource')
    });
  
    module.exports = router;
  </code></pre>
  
  <p>Passport index file</p>
  
  <pre><code>const passport = require('passport');
  
  const SignupStrategy = require('./SignupStrategy');
  const SigninStrategy = require('./SigninStrategy');
  
  passport.use('local-signin', SigninStrategy);
  passport.use('local-signup', SignupStrategy);
  
  module.exports = passport;
  </code></pre>
  
  <p>If I set allowNull to true in the user model, I'm getting the validation error from sequelize (Not null violation). Not sure what to do now</p>