GWM : removed password scope
This commit is contained in:
parent
510fc030ec
commit
7613a5f9b7
@ -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) => {
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user