【add】登录采用RSA加密的模式进行处理用户名和密码
This commit is contained in:
Generated
+5
@@ -9570,6 +9570,11 @@
|
|||||||
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
|
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"jsencrypt": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jsencrypt/-/jsencrypt-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-A4fIgyPN38G7wwB5t1Vkpi+w7j/nHKdradl/k9/GQqwAsxJqAJ55j3P5rWO3dvjhzOyWKOmK//WwzPO+o6gW0g=="
|
||||||
|
},
|
||||||
"jsesc": {
|
"jsesc": {
|
||||||
"version": "0.5.0",
|
"version": "0.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
"enquire.js": "^2.1.6",
|
"enquire.js": "^2.1.6",
|
||||||
"js-base64": "^3.6.0",
|
"js-base64": "^3.6.0",
|
||||||
"js-cookie": "^2.2.0",
|
"js-cookie": "^2.2.0",
|
||||||
|
"jsencrypt": "^3.0.0-rc.1",
|
||||||
"lodash.get": "^4.4.2",
|
"lodash.get": "^4.4.2",
|
||||||
"lodash.pick": "^4.4.0",
|
"lodash.pick": "^4.4.0",
|
||||||
"md5": "^2.2.1",
|
"md5": "^2.2.1",
|
||||||
|
|||||||
@@ -71,4 +71,19 @@ export function thirdLogin(token,thirdType) {
|
|||||||
'Content-Type': 'application/json;charset=UTF-8'
|
'Content-Type': 'application/json;charset=UTF-8'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取RSA公钥
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
export function getRSAPublicKey() {
|
||||||
|
return axios({
|
||||||
|
url: `/sys/getRSAPublicKey`,
|
||||||
|
method: 'get',
|
||||||
|
timeout: 5000,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json;charset=UTF-8'
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
@@ -182,6 +182,9 @@
|
|||||||
import { ACCESS_TOKEN ,ENCRYPTED_STRING} from "@/store/mutation-types"
|
import { ACCESS_TOKEN ,ENCRYPTED_STRING} from "@/store/mutation-types"
|
||||||
import { putAction,postAction,getAction } from '@/api/manage'
|
import { putAction,postAction,getAction } from '@/api/manage'
|
||||||
import { USER_INFO } from "@/store/mutation-types"
|
import { USER_INFO } from "@/store/mutation-types"
|
||||||
|
import {getRSAPublicKey} from '@/api/login.js'
|
||||||
|
const Base64 = require('js-base64').Base64
|
||||||
|
import {JSEncrypt} from 'jsencrypt'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {},
|
components: {},
|
||||||
@@ -211,6 +214,7 @@
|
|||||||
currdatetime:'',
|
currdatetime:'',
|
||||||
randCodeImage:'',
|
randCodeImage:'',
|
||||||
requestCodeSuccess:false,
|
requestCodeSuccess:false,
|
||||||
|
rsaPublicKey:''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
@@ -218,6 +222,7 @@
|
|||||||
Vue.ls.remove(ACCESS_TOKEN)
|
Vue.ls.remove(ACCESS_TOKEN)
|
||||||
this.getRouterData();
|
this.getRouterData();
|
||||||
this.handleChangeCheckCode();
|
this.handleChangeCheckCode();
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['Login', 'Logout', 'PhoneLogin']),
|
...mapActions(['Login', 'Logout', 'PhoneLogin']),
|
||||||
@@ -236,14 +241,19 @@
|
|||||||
that.loginBtn = true;
|
that.loginBtn = true;
|
||||||
that.form.validateFields([ 'username', 'password','inputCode', 'rememberMe' ], { force: true }, (err, values) => {
|
that.form.validateFields([ 'username', 'password','inputCode', 'rememberMe' ], { force: true }, (err, values) => {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
loginParams.username = values.username
|
|
||||||
loginParams.password = values.password
|
|
||||||
loginParams.remember_me = values.rememberMe
|
loginParams.remember_me = values.rememberMe
|
||||||
loginParams.captcha = that.inputCodeContent
|
loginParams.captcha = that.inputCodeContent
|
||||||
loginParams.checkKey = that.currdatetime
|
loginParams.checkKey = that.currdatetime
|
||||||
// console.log("登录参数",loginParams)
|
loginParams.rsaPublicKey = that.rsaPublicKey;
|
||||||
|
// 新建JSEncrypt对象
|
||||||
|
let encrypt = new JSEncrypt();
|
||||||
|
encrypt.setPublicKey(loginParams.rsaPublicKey);
|
||||||
|
// 公钥加密
|
||||||
|
loginParams.username = encrypt.encrypt(values.username)
|
||||||
|
loginParams.password = encrypt.encrypt(values.password)
|
||||||
|
//登录
|
||||||
that.Login(loginParams).then((res) => {
|
that.Login(loginParams).then((res) => {
|
||||||
//登录成功
|
|
||||||
this.loginSuccess()
|
this.loginSuccess()
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
if (err.code === 500) {
|
if (err.code === 500) {
|
||||||
@@ -309,6 +319,14 @@
|
|||||||
}).catch(()=>{
|
}).catch(()=>{
|
||||||
this.requestCodeSuccess=false
|
this.requestCodeSuccess=false
|
||||||
})
|
})
|
||||||
|
this.getPublicKey();
|
||||||
|
},
|
||||||
|
//获取RSA公钥
|
||||||
|
getPublicKey(){
|
||||||
|
// 获取公钥
|
||||||
|
getRSAPublicKey().then(res => {
|
||||||
|
this.rsaPublicKey = res.result
|
||||||
|
})
|
||||||
},
|
},
|
||||||
loginSuccess () {
|
loginSuccess () {
|
||||||
this.$router.push({ path: "/dashboard/analysis" }).catch((res)=>{})
|
this.$router.push({ path: "/dashboard/analysis" }).catch((res)=>{})
|
||||||
|
|||||||
Reference in New Issue
Block a user