1
This commit is contained in:
@@ -75,7 +75,7 @@ module.exports = {
|
||||
* example: '用户不存在或密码错误'
|
||||
*/
|
||||
"POST /user/login": async (ctx) => {
|
||||
const { login_name:email, password, device_id: client_device_id } = ctx.getBody();
|
||||
const { login_name: email, password, device_id: client_device_id } = ctx.getBody();
|
||||
const dayjs = require('dayjs');
|
||||
const { verifyPassword, validateDeviceId, maskEmail } = require('../utils/crypto_utils');
|
||||
|
||||
@@ -87,16 +87,6 @@ module.exports = {
|
||||
// 统一邮箱地址为小写
|
||||
const email_normalized = email.toLowerCase().trim();
|
||||
|
||||
// 验证邮箱格式
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
if (!emailRegex.test(email_normalized)) {
|
||||
return ctx.fail('邮箱格式不正确');
|
||||
}
|
||||
|
||||
// 验证密码长度
|
||||
if (password.length < 6 || password.length > 50) {
|
||||
return ctx.fail('密码长度不正确');
|
||||
}
|
||||
|
||||
const { pla_account } = await Framework.getModels();
|
||||
|
||||
@@ -404,17 +394,17 @@ module.exports = {
|
||||
|
||||
// 获取原有配置
|
||||
const original_deliver_config = user.deliver_config || {};
|
||||
|
||||
|
||||
// 深度合并配置(只覆盖传入的字段,保留原有的其他字段)
|
||||
const deepMerge = (target, source) => {
|
||||
const result = { ...target };
|
||||
Object.keys(source).forEach(key => {
|
||||
const sourceValue = source[key];
|
||||
const targetValue = target[key];
|
||||
|
||||
|
||||
// 如果源值是对象且目标值也是对象,递归合并(排除数组)
|
||||
if (sourceValue && typeof sourceValue === 'object' && !Array.isArray(sourceValue) &&
|
||||
targetValue && typeof targetValue === 'object' && !Array.isArray(targetValue)) {
|
||||
targetValue && typeof targetValue === 'object' && !Array.isArray(targetValue)) {
|
||||
result[key] = deepMerge(targetValue, sourceValue);
|
||||
} else {
|
||||
// 否则直接覆盖
|
||||
@@ -423,7 +413,7 @@ module.exports = {
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
const new_deliver_config = deepMerge(original_deliver_config, deliver_config);
|
||||
|
||||
// 处理 auto_deliver 字段(支持 auto_deliver 和 auto_delivery 两种字段名)
|
||||
@@ -447,7 +437,7 @@ module.exports = {
|
||||
|
||||
console.log('[保存投递配置成功]', {
|
||||
sn_code,
|
||||
deliver_config:new_deliver_config,
|
||||
deliver_config: new_deliver_config,
|
||||
auto_deliver: auto_deliver_value,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user