修改政府端前端,银行端小程序和后端接口

This commit is contained in:
2025-09-26 17:52:50 +08:00
parent 852adbcfff
commit 00dfa83fd1
237 changed files with 9172 additions and 33500 deletions

View File

@@ -16,6 +16,9 @@ class User extends BaseModel {
*/
async validPassword(password) {
try {
if (!password || !this.password) {
return false;
}
const bcrypt = require('bcryptjs');
return await bcrypt.compare(password, this.password);
} catch (error) {
@@ -178,12 +181,12 @@ User.init({
updatedAt: 'updated_at',
hooks: {
beforeCreate: async (user) => {
if (user.password) {
if (user.password && !user.password.startsWith('$2a$')) {
user.password = await bcrypt.hash(user.password, 10);
}
},
beforeUpdate: async (user) => {
if (user.changed('password')) {
if (user.changed('password') && user.password && !user.password.startsWith('$2a$')) {
user.password = await bcrypt.hash(user.password, 10);
}
}