明文加解密
This commit is contained in:
parent
82d80aa1b7
commit
fd668b51ee
|
|
@ -105,8 +105,11 @@ export const constantRoutes = [
|
||||||
path: '/qrCode/qrCodePage',
|
path: '/qrCode/qrCodePage',
|
||||||
component: () => import('@/views/qrCode/qrCode'),
|
component: () => import('@/views/qrCode/qrCode'),
|
||||||
hidden: true
|
hidden: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/resetPassword',
|
||||||
|
component: () => import('@/views/resetPassword'),
|
||||||
|
hidden: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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', 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)
|
||||||
|
|
@ -155,6 +155,7 @@ const user = {
|
||||||
commit('SET_ROLES', [])
|
commit('SET_ROLES', [])
|
||||||
commit('SET_PERMISSIONS', [])
|
commit('SET_PERMISSIONS', [])
|
||||||
removeToken()
|
removeToken()
|
||||||
|
localStorage.removeItem('isCode')
|
||||||
resolve()
|
resolve()
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject(error)
|
reject(error)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
type="password"
|
type="password"
|
||||||
auto-complete="off"
|
auto-complete="off"
|
||||||
placeholder="密码"
|
placeholder="密码"
|
||||||
|
show-password
|
||||||
@keyup.enter.native="handleLogin"
|
@keyup.enter.native="handleLogin"
|
||||||
>
|
>
|
||||||
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
|
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
|
||||||
|
|
@ -299,7 +300,13 @@ export default {
|
||||||
this.$store
|
this.$store
|
||||||
.dispatch('Login', this.loginForm)
|
.dispatch('Login', this.loginForm)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
if (localStorage.getItem('isCode') == 1) {
|
||||||
|
this.$router
|
||||||
|
.push({ path: '/resetPassword' })
|
||||||
|
.catch(() => {})
|
||||||
|
} else {
|
||||||
this.$router.push({ path: '/' }).catch(() => {})
|
this.$router.push({ path: '/' }).catch(() => {})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,7 @@
|
||||||
<div class="login-bar">
|
<div class="login-bar">
|
||||||
<div class="form-bar">
|
<div class="form-bar">
|
||||||
<h3 class="title">请重置登录密码</h3>
|
<h3 class="title">请重置登录密码</h3>
|
||||||
<el-form
|
<el-form ref="form" :model="user" :rules="rules">
|
||||||
ref="form"
|
|
||||||
:model="user"
|
|
||||||
:rules="rules"
|
|
||||||
>
|
|
||||||
<el-form-item label="旧密码" prop="oldPassword">
|
<el-form-item label="旧密码" prop="oldPassword">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="user.oldPassword"
|
v-model="user.oldPassword"
|
||||||
|
|
@ -33,10 +29,15 @@
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" style="width: 48.5%;" @click="submit"
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
style="width: 48.5%"
|
||||||
|
@click="submit"
|
||||||
>确认修改</el-button
|
>确认修改</el-button
|
||||||
>
|
>
|
||||||
<el-button style="width: 48.5%;" @click="close">返回登录页</el-button>
|
<el-button style="width: 48.5%" @click="close"
|
||||||
|
>返回登录页</el-button
|
||||||
|
>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -47,6 +48,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() {
|
||||||
|
|
@ -116,34 +118,23 @@
|
||||||
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(
|
||||||
).then((response) => {
|
(response) => {
|
||||||
this.$modal.msgSuccess('修改成功')
|
this.$modal.msgSuccess('修改成功')
|
||||||
// 进入首页
|
// 进入首页
|
||||||
this.$store.dispatch('LogOut').then(() => {
|
this.$store.dispatch('LogOut').then(() => {
|
||||||
// location.href = '/login';
|
location.href = '/login'
|
||||||
// location.href = '/gl/login';
|
|
||||||
|
|
||||||
location.href =
|
|
||||||
process.env.NODE_ENV === 'production-nw'
|
|
||||||
? '/gl/login'
|
|
||||||
: '/login'
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
close() {
|
close() {
|
||||||
this.$store.dispatch('LogOut').then(() => {
|
this.$store.dispatch('LogOut').then(() => {
|
||||||
// location.href = '/login';
|
location.href = '/login'
|
||||||
// location.href = '/gl/login';
|
|
||||||
|
|
||||||
location.href =
|
|
||||||
process.env.NODE_ENV === 'production-nw'
|
|
||||||
? '/gl/login'
|
|
||||||
: '/login'
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -551,6 +551,7 @@ import {
|
||||||
import { getToken } from '@/utils/auth'
|
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 { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'User',
|
name: 'User',
|
||||||
|
|
@ -698,7 +699,7 @@ export default {
|
||||||
this.getList()
|
this.getList()
|
||||||
this.getDeptTree()
|
this.getDeptTree()
|
||||||
this.getConfigKey('sys.user.initPassword').then((response) => {
|
this.getConfigKey('sys.user.initPassword').then((response) => {
|
||||||
this.initPassword = response.msg
|
this.initPassword = decrypt(response.msg)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -837,8 +838,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() {
|
||||||
|
|
@ -66,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