fix(user): persist updateUser correctly; add setup:api script and README update; seeders tweaks

This commit is contained in:
2025-12-05 01:33:38 +01:00
parent bd263c01b9
commit b710b34569
20 changed files with 1637 additions and 53 deletions
+4 -4
View File
@@ -11,7 +11,7 @@ const UserModel = () => {
User.init(
{
id: {
type: DataTypes.STRING(24),
type: DataTypes.UUID(),
allowNull: false,
primaryKey: true
},
@@ -87,16 +87,16 @@ const UserModel = () => {
}
);
User.beforeCreate((user) => {
/*User.beforeCreate((user) => {
if (typeof user.username === 'undefined') {
user.username = `${user.firstname}_${user.lastname}`;
}
user.setPassword(user.password);
user.role = 'User';
});
});*/
User.prototype.validPassword = function (password) {
let hash = crypto.pbkdf2Sync(password, this.salt, 10000, 512, 'sha512').toString('hex');
const hash = crypto.pbkdf2Sync(password, this.salt, 10000, 512, 'sha512').toString('hex');
return this.hash === hash;
};