diff --git a/backend/app.js b/backend/app.js index 31c41ca..496f035 100644 --- a/backend/app.js +++ b/backend/app.js @@ -15,7 +15,7 @@ app.use(express.json()); app.use(express.urlencoded({ extended: true })); // database -const db = require("./models/index"); +const db = require("./models"); const Role = db.Role; const User = db.User; const PitchType = db.PitchType; diff --git a/backend/models/user.model.js b/backend/models/user.model.js index f921657..13dee2a 100644 --- a/backend/models/user.model.js +++ b/backend/models/user.model.js @@ -52,6 +52,15 @@ module.exports = (sequelize, DataTypes) => { user.password = await bcrypt.hash(user.password, salt); } } + }, { + defaultScope: { + attributes: { exclude: ['password'] }, + }, + scopes: { + withSecretColumns: { + attributes: { include: ['password'] }, + }, + }, }); User.prototype.validPassword = function (password) { @@ -59,4 +68,4 @@ module.exports = (sequelize, DataTypes) => { }; return User; -}; \ No newline at end of file +};