Commit d156213a authored by 张伯涛's avatar 张伯涛

密码加密

parent 3bc87d82
...@@ -16,7 +16,12 @@ export function encrypt(data) { ...@@ -16,7 +16,12 @@ export function encrypt(data) {
encryptor.setPublicKey(publicKey) encryptor.setPublicKey(publicKey)
return encryptor.encrypt(json) return encryptor.encrypt(json)
} }
export function encryptTwo(data) {
const json = data
const encryptor = new JSEncrypt()
encryptor.setPublicKey(publicKey)
return encryptor.encrypt(json)
}
export function decrypt(txt) { export function decrypt(txt) {
const encryptor = new JSEncrypt() const encryptor = new JSEncrypt()
encryptor.setPrivateKey('') encryptor.setPrivateKey('')
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
</template> </template>
<script> <script>
import { updateUserPwd } from '@/api/system/user.js' import { updateUserPwd } from '@/api/system/user.js'
import { encryptTwo } from '@/utils/jsencrypt'
export default { export default {
name: 'ReSetPsw', name: 'ReSetPsw',
components: {}, components: {},
...@@ -82,8 +83,8 @@ export default { ...@@ -82,8 +83,8 @@ export default {
this.$refs['pwdForm'].validate((vaild) => { this.$refs['pwdForm'].validate((vaild) => {
if (vaild) { if (vaild) {
const params = { const params = {
oldPassword: this.pwdList.oldPass, oldPassword: encryptTwo(this.pwdList.oldPass),
newPassword: this.pwdList.pass newPassword: encryptTwo(this.pwdList.pass)
} }
updateUserPwd(params).then(res => { updateUserPwd(params).then(res => {
this.$message.success('密码修改成功!') this.$message.success('密码修改成功!')
......
...@@ -406,6 +406,7 @@ ...@@ -406,6 +406,7 @@
</div> </div>
</template> </template>
<script> <script>
import { encryptTwo } from '@/utils/jsencrypt'
import { import {
listUser, listUser,
getUser, getUser,
...@@ -906,7 +907,7 @@ export default { ...@@ -906,7 +907,7 @@ export default {
this.$refs.ruleForm.validate(pass => { this.$refs.ruleForm.validate(pass => {
if (pass) { if (pass) {
this.userRestLoading = true this.userRestLoading = true
resetUserPwd(this.ruleForm.row, this.ruleForm.newPassword).then(response => { resetUserPwd(this.ruleForm.row, encryptTwo(this.ruleForm.newPassword)).then(response => {
if (response.code === 200) { if (response.code === 200) {
this.$message({ this.$message({
message: '修改成功', message: '修改成功',
...@@ -935,7 +936,18 @@ export default { ...@@ -935,7 +936,18 @@ export default {
this.getList() this.getList()
}) })
} else { } else {
addUser(this.form).then(response => { const paramsAdd = {
identity: this.form.identity,
username: this.form.username,
flag: 1,
name: this.form.name,
phone: this.form.phone,
deptId: this.form.deptId,
password: encryptTwo(this.form.password),
roleList: this.form.roleList,
remarks: this.form.remarks
}
addUser(paramsAdd).then(response => {
this.newId = response.data.businessId this.newId = response.data.businessId
this.$message({ this.$message({
message: '新增成功', type: 'success' message: '新增成功', type: 'success'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment