tab-tracker icon indicating copy to clipboard operation
tab-tracker copied to clipboard

repeated email accepted

Open Ihebdhouibi opened this issue 4 years ago • 3 comments

When I pass the request the same email it's accepted and increase the ID with the same email and password as the precedent user I had unique : true in my User.js file

Ihebdhouibi avatar May 23 '20 00:05 Ihebdhouibi

still required to view your User.js without it can't figure out where is the issue also if possible output of the mysql command DESC table_name;

prashantnirgun avatar May 23 '20 06:05 prashantnirgun

This is my User.js file module.exports = (sequelize, DataTypes) => sequelize.define('User', { email: { type: DataTypes.STRING, unique: true }, password: DataTypes.STRING })

I've been doing some research and It seems it's something related to sequelize and in order for it to set a unique constraint to the email I had to call .sync() on the model ( which is not recommended ) or add queryInterface.addIndex()

Still newbie with sequelize so I am completely confused what to do, besides changing the error message dynamically is challenging as well, I go dig into it

Ihebdhouibi avatar May 23 '20 15:05 Ihebdhouibi

it seems ok, I think you need to use sync forcefully option but it will erase your data. I personally not using not using sequelize as my project is not that big. I feel its like a tank to kill an ant so I am not using sequilize. In your case just juse force sync. That's all.

prashantnirgun avatar May 24 '20 05:05 prashantnirgun