接入用户密码接口前端加密

This commit is contained in:
wkc
2026-03-30 10:48:40 +08:00
parent b276654ac2
commit 8552514dcb
5 changed files with 13 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ ENV = 'development'
# 若依管理系统/开发环境 # 若依管理系统/开发环境
VUE_APP_BASE_API = '/dev-api' VUE_APP_BASE_API = '/dev-api'
VUE_APP_PASSWORD_TRANSFER_KEY = '1234567890abcdef'
# 路由懒加载 # 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true VUE_CLI_BABEL_TRANSPILE_MODULES = true

View File

@@ -6,3 +6,4 @@ ENV = 'production'
# 若依管理系统/生产环境 # 若依管理系统/生产环境
VUE_APP_BASE_API = '/prod-api' VUE_APP_BASE_API = '/prod-api'
VUE_APP_PASSWORD_TRANSFER_KEY = '1234567890abcdef'

View File

@@ -10,3 +10,4 @@ ENV = 'staging'
# 若依管理系统/测试环境 # 若依管理系统/测试环境
VUE_APP_BASE_API = '/stage-api' VUE_APP_BASE_API = '/stage-api'
VUE_APP_PASSWORD_TRANSFER_KEY = '1234567890abcdef'

View File

@@ -21,10 +21,11 @@ export function getUser(userId) {
// 新增用户 // 新增用户
export function addUser(data) { export function addUser(data) {
const payload = encryptPasswordFields(data, ['password'], process.env.VUE_APP_PASSWORD_TRANSFER_KEY)
return request({ return request({
url: '/system/user', url: '/system/user',
method: 'post', method: 'post',
data: data data: payload
}) })
} }
@@ -47,10 +48,10 @@ export function delUser(userId) {
// 用户密码重置 // 用户密码重置
export function resetUserPwd(userId, password) { export function resetUserPwd(userId, password) {
const data = { const data = encryptPasswordFields({
userId, userId,
password password
} }, ['password'], process.env.VUE_APP_PASSWORD_TRANSFER_KEY)
return request({ return request({
url: '/system/user/resetPwd', url: '/system/user/resetPwd',
method: 'put', method: 'put',

View File

@@ -79,4 +79,10 @@ const updatePwdConfig = userModule.updateUserPwd('oldPwd', 'newPwd')
assert.notStrictEqual(updatePwdConfig.data.oldPassword, 'oldPwd') assert.notStrictEqual(updatePwdConfig.data.oldPassword, 'oldPwd')
assert.notStrictEqual(updatePwdConfig.data.newPassword, 'newPwd') assert.notStrictEqual(updatePwdConfig.data.newPassword, 'newPwd')
const addUserConfig = userModule.addUser({ userName: 'u1', password: 'initPwd', nickName: 'n1' })
assert.notStrictEqual(addUserConfig.data.password, 'initPwd')
const resetUserPwdConfig = userModule.resetUserPwd(2, 'resetPwd')
assert.notStrictEqual(resetUserPwdConfig.data.password, 'resetPwd')
console.log('password-transfer-api test passed') console.log('password-transfer-api test passed')