Browse Source

loginWork登陆密码加密

preview
jianjun 5 years ago
parent
commit
a160daed21
  1. 1
      epmet-oper-web/package.json
  2. 98
      epmet-oper-web/src/views/pages/loginWork.vue

1
epmet-oper-web/package.json

@ -25,6 +25,7 @@
"gulp-rename": "^1.4.0",
"gulp-sass": "^4.0.2",
"js-cookie": "^2.2.0",
"jsencrypt": "^3.0.3",
"lodash": "^4.17.15",
"node-sass": "^4.12.0",
"portfinder": "^1.0.21",

98
epmet-oper-web/src/views/pages/loginWork.vue

@ -142,11 +142,13 @@ import debounce from 'lodash/debounce'
import { messages } from '@/i18n'
import { getUUID } from '@/utils'
import { Loading } from 'element-ui' // Loading
import JSEncrypt from 'jsencrypt'//
let loading //
export default {
data () {
return {
pubKey: null, //
isShowLogin: true,
i18nMessages: messages,
captchaPath: '',
@ -191,18 +193,31 @@ export default {
this.getAutoLogin(this.$route.query.platformToken)
}else{
this.getCaptcha()
localStorage.remove('showHeader')
//
this.getPubKey()
}
},
methods: {
//
getPubKey() {
this.$http.post('/auth/govweb/getKey').then(({data: res}) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.pubKey = res.data; // ;
console.log("pubkey", this.pubKey);
}).catch(() => {
})
},
//
getCaptcha () {
this.dataForm.uuid = getUUID()
this.captchaPath = `${window.SITE_CONFIG['apiURL']}/auth/login/captcha?uuid=${this.dataForm.uuid}`
},
//
dataFormSubmitHandle () {
dataFormSubmitHandle() {
this.$refs['dataForm'].validate((valid, messageObj) => {
if (!valid) {
app.util.validateRule(messageObj)
@ -214,38 +229,37 @@ export default {
phone: this.dataForm.phone
}
window.app.ajax.post(
url, params,
(data, rspMsg) => {
if (data.length === 0) {//
this.$message.error('账号不存在')
this.endLoading()
} else if (data.length === 1) {
this.selectCustomer(data[0])
} else {
this.endLoading()
this.diaVisible = true
this.$nextTick(() => {
this.tableData = data
})
}
},
(rspMsg, data) => {
this.endLoading()
this.$message.error(rspMsg)
})
url, params,
(data, rspMsg) => {
if (data.length === 0) {//
this.$message.error('账号不存在')
this.endLoading()
} else if (data.length === 1) {
this.selectCustomer(data[0])
} else {
this.endLoading()
this.diaVisible = true
this.$nextTick(() => {
this.tableData = data
})
}
},
(rspMsg, data) => {
this.endLoading()
this.$message.error(rspMsg)
})
})
},
//
getAutoLogin (platformToken) {
getAutoLogin(platformToken) {
this.dataForm.thirdToken = platformToken;
this.dataForm.platform = "pyld";
this.$http.post(`/auth/sso/oper/third/login`,this.dataForm).then(({ data: res }) => {
this.$http.post(`/auth/sso/oper/third/login`, this.dataForm).then(({data: res}) => {
if (res.code !== 0) {
if(res.code == 8302){
if (res.code == 8302) {
return this.$message.error(res.internalMsg)
}
return this.$message.error(res.msg)
@ -254,12 +268,13 @@ export default {
localStorage.setItem('userType', 'work')
localStorage.setItem('showHeader', '0')
Cookies.set('token', res.data.token)
this.$router.replace({ name: 'home' })
}).catch(() => { })
this.$router.replace({name: 'home'})
}).catch(() => {
})
// epmet-ext9.elinkservice.cn/platform-admin
},
//
selectCustomer (row) {
selectCustomer(row) {
localStorage.setItem('customerId', row.customerId)
localStorage.setItem('customerName', row.customerName)
this.startLoading()
@ -267,7 +282,10 @@ export default {
const url = '/auth/govweb/login'
this.dataForm.customerId = row.customerId
this.$http.post(url, this.dataForm).then(({ data: res }) => {
console.log('password pre', this.dataForm.password);
this.dataForm.password = this.encryptedData(this.pubKey, this.dataForm.password);
console.log('password after', this.dataForm.password);
this.$http.post(url, this.dataForm).then(({data: res}) => {
if (res.code !== 0) {
this.getCaptcha()
return this.$message.error(res.msg)
@ -277,18 +295,19 @@ export default {
localStorage.setItem('userType', 'work')
Cookies.set('token', res.data.token)
this.$router.replace({ name: 'home' })
}).catch(() => { })
this.$router.replace({name: 'home'})
}).catch(() => {
})
this.endLoading()
},
//
diaCancel () {
diaCancel() {
this.diaVisible = false
},
//
startLoading () {
startLoading() {
loading = Loading.service({
lock: true, //
text: '正在加载……', //
@ -296,13 +315,22 @@ export default {
})
},
//
endLoading () {
endLoading() {
// clearTimeout(timer);
if (loading) {
loading.close()
}
},
//
encryptedData(key, data) {
debugger
// JSEncrypt
let encryptor = new JSEncrypt();
//
encryptor.setPublicKey(key);
//
return encryptor.encrypt(data);
}
}
}

Loading…
Cancel
Save