明文加解密
This commit is contained in:
parent
3209f2279d
commit
ed6da1696e
|
|
@ -48,7 +48,7 @@ const user = {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
login(username, password, code, uuid).then(res => {
|
login(username, password, code, uuid).then(res => {
|
||||||
let data = res.data
|
let data = res.data
|
||||||
localStorage.setItem('isCode', res.data.code)
|
localStorage.setItem('isCode', data.code || '')
|
||||||
setToken(data.access_token)
|
setToken(data.access_token)
|
||||||
commit('SET_TOKEN', data.access_token)
|
commit('SET_TOKEN', data.access_token)
|
||||||
localStorage.setItem('token', data.access_token)
|
localStorage.setItem('token', data.access_token)
|
||||||
|
|
@ -154,6 +154,7 @@ const user = {
|
||||||
commit('SET_TOKEN', '')
|
commit('SET_TOKEN', '')
|
||||||
commit('SET_ROLES', [])
|
commit('SET_ROLES', [])
|
||||||
commit('SET_PERMISSIONS', [])
|
commit('SET_PERMISSIONS', [])
|
||||||
|
localStorage.removeItem('isCode')
|
||||||
removeToken()
|
removeToken()
|
||||||
resolve()
|
resolve()
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|
|
||||||
|
|
@ -507,15 +507,13 @@ export default {
|
||||||
this.$store
|
this.$store
|
||||||
.dispatch('Login', this.loginForm)
|
.dispatch('Login', this.loginForm)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// if (localStorage.getItem('isCode') == 1) {
|
if (localStorage.getItem('isCode') == 1) {
|
||||||
// this.$router
|
this.$router.push({ path: '/resetPassword' }).catch(() => {})
|
||||||
// .push({ path: '/resetPassword' })
|
} else {
|
||||||
// .catch(() => {})
|
this.$router.push({ path: '/' }).catch(() => {})
|
||||||
// } else {
|
}
|
||||||
// this.$router.push({ path: '/' }).catch(() => {})
|
|
||||||
// }
|
|
||||||
|
|
||||||
this.$router.push({ path: '/' }).catch(() => {})
|
// this.$router.push({ path: '/' }).catch(() => {})
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,11 @@
|
||||||
<script>
|
<script>
|
||||||
import { updateUserPwd } from '@/api/system/user'
|
import { updateUserPwd } from '@/api/system/user'
|
||||||
import { validPassword } from '@/utils/validate'
|
import { validPassword } from '@/utils/validate'
|
||||||
|
import { encrypt } from '@/utils/jsencrypt.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
const passwordRegex = (rule, value, callback) => {
|
const passwordRegex = (rule, value, callback) => {
|
||||||
// const reg =
|
|
||||||
// /^((?=.*[A-Za-z])(?=.*\d)|(?=.*[A-Za-z])(?=.*[!@#$%^&*()_+\-\=])|(?=.*\d)(?=.*[!@#$%^&*()_+\-\=]))[A-Za-z\d!@#$%^&*()_+\-\=]{8,20}$/
|
|
||||||
if (value.length < 8 || value.length > 20) {
|
if (value.length < 8 || value.length > 20) {
|
||||||
callback(new Error('密码长度在 8 到 20 个字符'))
|
callback(new Error('密码长度在 8 到 20 个字符'))
|
||||||
} else if (!validPassword(value)) {
|
} else if (!validPassword(value)) {
|
||||||
|
|
@ -119,10 +118,9 @@ export default {
|
||||||
submit() {
|
submit() {
|
||||||
this.$refs['form'].validate((valid) => {
|
this.$refs['form'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
updateUserPwd(
|
const oldPassword = encrypt(this.user.oldPassword)
|
||||||
this.user.oldPassword,
|
const newPassword = encrypt(this.user.newPassword)
|
||||||
this.user.newPassword,
|
updateUserPwd(oldPassword, newPassword).then((response) => {
|
||||||
).then((response) => {
|
|
||||||
this.$modal.msgSuccess('修改成功')
|
this.$modal.msgSuccess('修改成功')
|
||||||
// 进入首页
|
// 进入首页
|
||||||
this.$store.dispatch('LogOut').then(() => {
|
this.$store.dispatch('LogOut').then(() => {
|
||||||
|
|
|
||||||
|
|
@ -551,7 +551,7 @@ import { getToken } from '@/utils/auth'
|
||||||
import Treeselect from '@riophae/vue-treeselect'
|
import Treeselect from '@riophae/vue-treeselect'
|
||||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||||
import { validPassword } from '@/utils/validate'
|
import { validPassword } from '@/utils/validate'
|
||||||
import { decrypt } from '@/utils/jsencrypt.js'
|
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'User',
|
name: 'User',
|
||||||
|
|
@ -854,8 +854,9 @@ export default {
|
||||||
inputErrorMessage: '用户密码长度必须介于 5 和 20 之间',
|
inputErrorMessage: '用户密码长度必须介于 5 和 20 之间',
|
||||||
})
|
})
|
||||||
.then(({ value }) => {
|
.then(({ value }) => {
|
||||||
resetUserPwd(row.userId, value).then((response) => {
|
const password = encrypt(value)
|
||||||
this.$modal.msgSuccess('修改成功,新密码是:' + value)
|
resetUserPwd(row.userId, password).then((response) => {
|
||||||
|
this.$modal.msgSuccess('修改成功')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { updateUserPwd } from "@/api/system/user";
|
import { updateUserPwd } from "@/api/system/user";
|
||||||
import { validPassword } from '@/utils/validate'
|
import { validPassword } from '@/utils/validate'
|
||||||
|
import { encrypt } from '@/utils/jsencrypt.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
|
@ -27,6 +28,8 @@ export default {
|
||||||
callback(new Error("密码长度在 8 到 20 个字符"));
|
callback(new Error("密码长度在 8 到 20 个字符"));
|
||||||
} else if (!validPassword(value)) {
|
} else if (!validPassword(value)) {
|
||||||
callback(new Error("密码须包含数字、字母、特殊符号中的两种以上"));
|
callback(new Error("密码须包含数字、字母、特殊符号中的两种以上"));
|
||||||
|
} else if (this.user.oldPassword === value) {
|
||||||
|
callback(new Error('新密码不能与旧密码相同'))
|
||||||
} else {
|
} else {
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +67,9 @@ export default {
|
||||||
submit() {
|
submit() {
|
||||||
this.$refs["form"].validate(valid => {
|
this.$refs["form"].validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
updateUserPwd(this.user.oldPassword, this.user.newPassword).then(response => {
|
const oldPassword = encrypt(this.user.oldPassword)
|
||||||
|
const newPassword = encrypt(this.user.newPassword)
|
||||||
|
updateUserPwd(oldPassword, newPassword).then(response => {
|
||||||
this.$modal.msgSuccess("修改成功");
|
this.$modal.msgSuccess("修改成功");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue