mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-08 17:12:28 +08:00
登录密码加密解码报错处理
This commit is contained in:
@ -13,6 +13,7 @@ export const USER_NAME = 'Login_Username'
|
||||
export const USER_INFO = 'Login_Userinfo'
|
||||
export const USER_AUTH = 'LOGIN_USER_BUTTON_AUTH'
|
||||
export const SYS_BUTTON_AUTH = 'SYS_BUTTON_AUTH'
|
||||
export const ENCRYPTED_STRING = 'ENCRYPTED_STRING'
|
||||
|
||||
export const CONTENT_WIDTH_TYPE = {
|
||||
Fluid: 'Fluid',
|
||||
|
||||
@ -1,4 +1,19 @@
|
||||
import { getAction } from '@/api/manage'
|
||||
import { ENCRYPTED_STRING } from "@/store/mutation-types"
|
||||
import Vue from 'vue'
|
||||
|
||||
/**
|
||||
* 获取加密字符串,并对结果进行缓存
|
||||
*/
|
||||
export function getEncryptedString() {
|
||||
return getAction("/sys/getEncryptedString",{}).then((res)=>{
|
||||
let encryptedString = {};
|
||||
encryptedString.key = res.result.key;
|
||||
encryptedString.iv = res.result.iv;
|
||||
Vue.ls.set(ENCRYPTED_STRING, encryptedString, 7 * 24 * 60 * 60 * 1000);
|
||||
return encryptedString;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* AES加密 :字符串 key iv 返回base64
|
||||
|
||||
@ -171,12 +171,11 @@
|
||||
import { mapActions } from "vuex"
|
||||
import { timeFix } from "@/utils/util"
|
||||
import Vue from 'vue'
|
||||
import { ACCESS_TOKEN } from "@/store/mutation-types"
|
||||
import { ACCESS_TOKEN ,ENCRYPTED_STRING} from "@/store/mutation-types"
|
||||
import JGraphicCode from '@/components/jeecg/JGraphicCode'
|
||||
import { putAction } from '@/api/manage'
|
||||
import { postAction } from '@/api/manage'
|
||||
import { getAction} from '@/api/manage'
|
||||
import { encryption } from '@/utils/encryption/aesEncrypt'
|
||||
import { encryption , getEncryptedString } from '@/utils/encryption/aesEncrypt'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -192,6 +191,10 @@
|
||||
requiredTwoStepCaptcha: false,
|
||||
stepCaptchaVisible: false,
|
||||
form: this.$form.createForm(this),
|
||||
encryptedString:{
|
||||
key:"",
|
||||
iv:"",
|
||||
},
|
||||
state: {
|
||||
time: 60,
|
||||
smsSendBtn: false,
|
||||
@ -224,6 +227,7 @@
|
||||
created () {
|
||||
Vue.ls.remove(ACCESS_TOKEN)
|
||||
this.getRouterData();
|
||||
this.getEncrypte();
|
||||
// update-begin- --- author:scott ------ date:20190225 ---- for:暂时注释,未实现登录验证码功能
|
||||
// this.$http.get('/auth/2step-code')
|
||||
// .then(res => {
|
||||
@ -256,23 +260,23 @@
|
||||
let loginParams = {
|
||||
remember_me: that.formLogin.rememberMe
|
||||
};
|
||||
|
||||
that.loginBtn = true;
|
||||
// 使用账户密码登陆
|
||||
if (that.customActiveKey === 'tab1') {
|
||||
that.form.validateFields([ 'username', 'password','inputCode' ], { force: true }, (err, values) => {
|
||||
if (!err) {
|
||||
getAction("/sys/getEncryptedString",{}).then((res)=>{
|
||||
loginParams.username = values.username
|
||||
//loginParams.password = md5(values.password)
|
||||
loginParams.password = encryption(values.password,res.result.key,res.result.iv)
|
||||
that.Login(loginParams).then((res) => {
|
||||
this.departConfirm(res)
|
||||
}).catch((err) => {
|
||||
that.requestFailed(err);
|
||||
})
|
||||
loginParams.username = values.username
|
||||
//loginParams.password = md5(values.password)
|
||||
loginParams.password = encryption(values.password,that.encryptedString.key,that.encryptedString.iv).replace(/\+/g,"%2B");
|
||||
that.Login(loginParams).then((res) => {
|
||||
this.departConfirm(res)
|
||||
}).catch((err) => {
|
||||
that.requestFailed(err);
|
||||
});
|
||||
|
||||
|
||||
}else {
|
||||
that.loginBtn = false;
|
||||
}
|
||||
})
|
||||
// 使用手机号登陆
|
||||
@ -453,6 +457,17 @@
|
||||
});
|
||||
})
|
||||
},
|
||||
//获取密码加密规则
|
||||
getEncrypte(){
|
||||
var encryptedString = Vue.ls.get(ENCRYPTED_STRING);
|
||||
if(encryptedString == null){
|
||||
getEncryptedString().then((data) => {
|
||||
this.encryptedString = data
|
||||
});
|
||||
}else{
|
||||
this.encryptedString = encryptedString;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user