WMS_MAIN/database/migrations/20261025135000-add-is-custom-password-to-wms-account.js
liufumingren 640ce501cb feat(user): 新增账号用户名/密码修改与自定义密码标记
- wms_account 新增 is_custom_password(TINYINT(1) NOT NULL DEFAULT 0),同步模型与迁移 20261025135000;开发库、生产库均已执行

- user.getAccountInfo 返回 is_custom_password,仍不返回 password_hash/salt/last_login_ip

- 新增 user.updateUsername:仅改当前账号,服务端重名校验并排除自己,重名返回 409,更新后清理用户缓存

- 新增 user.changePassword:is_custom_password=0 时旧密码可不传,修改后置 1;再次修改必须校验旧密码;已排除操作日志避免明文密码落库

- 单测覆盖 getAccountInfo/updateUsername/changePassword,20 通过;同步 AI_METHOD_ROUTING

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-27 03:08:51 +08:00

45 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 为账号表新增“是否自定义密码”标记。
*/
module.exports = {
/**
* 执行迁移:新增 is_custom_password 字段(幂等)。
* @param {import('sequelize').QueryInterface} queryInterface 查询接口
* @param {import('sequelize')} Sequelize Sequelize 实例
* @return {Promise<void>} 无返回值
*/
async up(queryInterface, Sequelize) {
const tableName = 'wms_account';
const columns = await queryInterface.describeTable(tableName);
if (columns.is_custom_password) {
return;
}
await queryInterface.addColumn(tableName, 'is_custom_password', {
type: Sequelize.TINYINT(1),
allowNull: false,
defaultValue: 0,
comment: '是否自定义密码:0-否,1-是',
});
},
/**
* 回滚迁移:删除 is_custom_password 字段(幂等)。
* @param {import('sequelize').QueryInterface} queryInterface 查询接口
* @return {Promise<void>} 无返回值
*/
async down(queryInterface) {
const tableName = 'wms_account';
const columns = await queryInterface.describeTable(tableName);
if (!columns.is_custom_password) {
return;
}
await queryInterface.removeColumn(tableName, 'is_custom_password');
},
};