接入用户密码接口前端加密
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -6,3 +6,4 @@ ENV = 'production'
|
|||||||
|
|
||||||
# 若依管理系统/生产环境
|
# 若依管理系统/生产环境
|
||||||
VUE_APP_BASE_API = '/prod-api'
|
VUE_APP_BASE_API = '/prod-api'
|
||||||
|
VUE_APP_PASSWORD_TRANSFER_KEY = '1234567890abcdef'
|
||||||
|
|||||||
@@ -10,3 +10,4 @@ ENV = 'staging'
|
|||||||
|
|
||||||
# 若依管理系统/测试环境
|
# 若依管理系统/测试环境
|
||||||
VUE_APP_BASE_API = '/stage-api'
|
VUE_APP_BASE_API = '/stage-api'
|
||||||
|
VUE_APP_PASSWORD_TRANSFER_KEY = '1234567890abcdef'
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
@@ -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')
|
||||||
|
|||||||
Reference in New Issue
Block a user