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