diff --git a/app/models/establishment_user.model.js b/app/models/establishment_user.model.js index 99b2593..9426d17 100644 --- a/app/models/establishment_user.model.js +++ b/app/models/establishment_user.model.js @@ -65,30 +65,24 @@ module.exports = (sequelize, DataTypes) => { timestamps: false, tableName: "establishment_users", }, - { - // 1. EXCLUDE sensitive fields from all queries - defaultScope: { - attributes: { exclude: ["password", "reset_otp", "reset_otp_expires_at"] }, - }, + // { + // // 1. EXCLUDE sensitive fields from all queries + // defaultScope: { + // attributes: { exclude: ["password", "reset_otp", "reset_otp_expires_at"] }, + // }, - // 2. Ensure manual selections still hide sensitive fields - scopes: { - withSensitive: { - attributes: { include: ["password", "reset_otp", "reset_otp_expires_at"] }, - }, - }, - - // 3. Remove sensitive fields when converting to JSON - instanceMethods: { - toJSON() { - const values = { ...this.get() }; - delete values.password; - delete values.reset_otp; - delete values.reset_otp_expires_at; - return values; - }, - }, - } + // // ------------------------------------------------------------- + // // 2. Special scope for login or OTP flows + // // Use: User.scope("withSensitive").findOne(...) + // // ------------------------------------------------------------- + // scopes: { + // withSensitive: { + // attributes: { + // include: ["password", "reset_otp", "reset_otp_expires_at"], + // }, + // }, + // }, + // } ); EstablishmentUser.associate = (models) => { diff --git a/app/models/user.model.js b/app/models/user.model.js index e91a87d..46bfb24 100644 --- a/app/models/user.model.js +++ b/app/models/user.model.js @@ -35,30 +35,24 @@ module.exports = (sequelize, DataTypes) => { defaultValue: true, }, }, - { - // 1. EXCLUDE sensitive fields from all queries - defaultScope: { - attributes: { exclude: ["password", "reset_otp", "reset_otp_expires_at"] }, - }, + // { + // // 1. EXCLUDE sensitive fields from all queries + // defaultScope: { + // attributes: { exclude: ["password", "reset_otp", "reset_otp_expires_at"] }, + // }, - // 2. Ensure manual selections still hide sensitive fields - scopes: { - withSensitive: { - attributes: { include: ["password", "reset_otp", "reset_otp_expires_at"] }, - }, - }, - - // 3. Remove sensitive fields when converting to JSON - instanceMethods: { - toJSON() { - const values = { ...this.get() }; - delete values.password; - delete values.reset_otp; - delete values.reset_otp_expires_at; - return values; - }, - }, - } + // // ------------------------------------------------------------- + // // 2. Special scope for login or OTP flows + // // Use: User.scope("withSensitive").findOne(...) + // // ------------------------------------------------------------- + // scopes: { + // withSensitive: { + // attributes: { + // include: ["password", "reset_otp", "reset_otp_expires_at"], + // }, + // }, + // }, + // } ); return User;