Commit b9c76e1c authored by 徐乐's avatar 徐乐

perf: 增加第三方免密跳转加密

parent 52a86b10
Pipeline #97114 passed with stages
/* eslint-disable */ /* eslint-disable */
// const proxyURL = process.env.NODE_ENV !== 'production' ? 'http://192.168.10.150:8777' : window.location.origin; // const proxyURL = process.env.NODE_ENV !== 'production' ? 'http://192.168.10.150:8777' : window.location.origin;
// const proxyURL = 'https://work.panda-water.cn'; // const proxyURL = 'https://work.panda-water.cn';
const proxyURL = 'http://192.168.10.182:8099/'; const proxyURL = 'http://localhost:8090/';
// const proxyURL = 'https://panda-water.cn' // const proxyURL = 'https://panda-water.cn'
//const proxyURL = 'http://192.168.12.189:8816/' //const proxyURL = 'http://192.168.12.189:8816/'
module.exports = { module.exports = {
......
...@@ -1363,7 +1363,6 @@ class Login { ...@@ -1363,7 +1363,6 @@ class Login {
path: '/', path: '/',
}); });
} }
debugger
sessionStorage.setItem('client', self.globalConfig.client); sessionStorage.setItem('client', self.globalConfig.client);
self.isSignIn = true; self.isSignIn = true;
self.updateConfig && self.updateConfig(self.globalConfig); self.updateConfig && self.updateConfig(self.globalConfig);
......
...@@ -10,6 +10,7 @@ import { getUserInfo, getWebSiteConfig } from '@/api/service/base'; ...@@ -10,6 +10,7 @@ import { getUserInfo, getWebSiteConfig } from '@/api/service/base';
import { SERVICE_APP_LOGIN_MODE, SERVICE_INTERFACE_SUCCESS_CODE, WX_REDIRECT_URI } from '@/constants'; import { SERVICE_APP_LOGIN_MODE, SERVICE_INTERFACE_SUCCESS_CODE, WX_REDIRECT_URI } from '@/constants';
import store from '@/stores'; import store from '@/stores';
import { defaultApp } from '@/micro'; import { defaultApp } from '@/micro';
import CryptoJS from 'crypto-js';
import { import {
DEFAULT_MQTT_PATH, DEFAULT_MQTT_PATH,
...@@ -36,21 +37,38 @@ class Login { ...@@ -36,21 +37,38 @@ class Login {
// 单点登录_xule_20231214 // 单点登录_xule_20231214
const queryString = window.location.search.substring(1); const queryString = window.location.search.substring(1);
const params = queryString.split('&'); const params = queryString.split('&');
const paramsFind = const paramsFind = params && params.find(function (a) { return a.split('=')[0] == 'uniwater_utoken'; });
params &&
params.find(function(a) {
return a.split('=')[0] == 'uniwater_utoken';
});
this.uniwater_utoken = paramsFind?.split('=')[1] ?? ''; this.uniwater_utoken = paramsFind?.split('=')[1] ?? '';
// 单页面免登重定向地址 // 单页面免登重定向地址
const redirect = const redirect = params && params.find(function (a) { return a.split('=')[0] === 'redirect'; });
params &&
params.find(function(a) {
return a.split('=')[0] === 'redirect';
});
if (this.uniwater_utoken && !redirect) { if (this.uniwater_utoken && !redirect) {
this.getTokenForThird(); this.getTokenForThird();
} }
//第三方免密登录,通过账号加密的方式,链接有效期30s_xule_20250427
const loginName = params && params.find(function (a) { return a.split('=')[0] === 'loginName'; })?.split('=')[1] || '';
if (loginName) {
const generateType = params && params.find(function (a) { return a.split('=')[0] === 'type'; })?.split('=')[1] || '';
const initiateTime = params && params.find(function (a) { return a.split('=')[0] === 'time'; })?.split('=')[1] || '';
const eiv = params && params.find(function (a) { return a.split('=')[0] === 'key'; })?.split('=')[1] || '';
let newTime = new Date().getTime() - initiateTime * 1;
if (generateType == 'pandaoa' && newTime > 0 && newTime < 30000 && eiv) {
const key = CryptoJS.PBKDF2(initiateTime, '', {
keySize: 256 / 32,
iterations: 100000
});
const iv = CryptoJS.enc.Hex.parse(eiv);
const decrypted = CryptoJS.AES.decrypt(loginName, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
const enLoginName = decrypted.toString(CryptoJS.enc.Utf8);
this.login(enLoginName, '', '', false, 'password', '', generateType);
return;
}
}
this.createContext = props.createContext; this.createContext = props.createContext;
this.history = props.history; this.history = props.history;
...@@ -152,8 +170,8 @@ class Login { ...@@ -152,8 +170,8 @@ class Login {
(response.token (response.token
? response.token ? response.token
: response.access_token !== null && response.user_token !== null : response.access_token !== null && response.user_token !== null
? response.user_token ? response.user_token
: ''); : '');
if (token) { if (token) {
const exp = 86400000; const exp = 86400000;
self.globalConfig.token = token; self.globalConfig.token = token;
...@@ -355,7 +373,7 @@ class Login { ...@@ -355,7 +373,7 @@ class Login {
? this.globalConfig.userInfo.fullName ? this.globalConfig.userInfo.fullName
: '', : '',
}) })
.catch(error => {}); .catch(error => { });
} }
if (window.location.host === 'panda-water.com') { if (window.location.host === 'panda-water.com') {
...@@ -369,7 +387,7 @@ class Login { ...@@ -369,7 +387,7 @@ class Login {
? this.globalConfig.userInfo.fullName ? this.globalConfig.userInfo.fullName
: '', : '',
}) })
.catch(error => {}); .catch(error => { });
} }
} }
...@@ -435,10 +453,10 @@ class Login { ...@@ -435,10 +453,10 @@ class Login {
!res || !res.data !res || !res.data
? false ? false
: _.isString(res.data) : _.isString(res.data)
? JSON.parse(res.data) ? JSON.parse(res.data)
: typeof res.data === 'boolean' : typeof res.data === 'boolean'
? res.data ? res.data
: false; : false;
self.globalConfig.hasGateWay = hasGateWay; self.globalConfig.hasGateWay = hasGateWay;
self.globalConfig.apiGatewayDomain = `${window.location.origin}${hasGateWay ? '/PandaCore/GateWay' : ''}`; self.globalConfig.apiGatewayDomain = `${window.location.origin}${hasGateWay ? '/PandaCore/GateWay' : ''}`;
if (hasGateWay) { if (hasGateWay) {
...@@ -554,9 +572,8 @@ class Login { ...@@ -554,9 +572,8 @@ class Login {
mqttConfig.mqtt_mess.TcpPort = DEFAULT_TCP_PORT; mqttConfig.mqtt_mess.TcpPort = DEFAULT_TCP_PORT;
mqttConfig.mqtt_IsSSL = `${mqttConfig.mqtt_mess.TcpIP}:${mqttConfig.mqtt_mess.TcpPort}`; mqttConfig.mqtt_IsSSL = `${mqttConfig.mqtt_mess.TcpIP}:${mqttConfig.mqtt_mess.TcpPort}`;
} }
mqttConfig.mqtt_iotIP = `${mqttConfig.mqtt_mess.TcpIP}:${ mqttConfig.mqtt_iotIP = `${mqttConfig.mqtt_mess.TcpIP}:${mqttConfig.mqtt_mess.TcpPort ? mqttConfig.mqtt_mess.TcpPort : '443'
mqttConfig.mqtt_mess.TcpPort ? mqttConfig.mqtt_mess.TcpPort : '443' }`;
}`;
self.globalConfig = Object.assign(self.globalConfig, { self.globalConfig = Object.assign(self.globalConfig, {
...mqttConfig, ...mqttConfig,
}); });
...@@ -582,8 +599,8 @@ class Login { ...@@ -582,8 +599,8 @@ class Login {
const homepage = params.getParams('homepage') const homepage = params.getParams('homepage')
? params.getParams('homepage') ? params.getParams('homepage')
: homeType && config.homepage : homeType && config.homepage
? `${homeType}/${params.getParams('homepage') || config.homepage}` ? `${homeType}/${params.getParams('homepage') || config.homepage}`
: ''; : '';
window.qiankunIsCache = window.qiankunIsCache =
window.location.origin.replace(/^(http|https):\/\//, '') === 'panda-water.cn' window.location.origin.replace(/^(http|https):\/\//, '') === 'panda-water.cn'
? false ? false
...@@ -1011,7 +1028,7 @@ class Login { ...@@ -1011,7 +1028,7 @@ class Login {
height: '400', height: '400',
}); });
const handleMessage = function(event) { const handleMessage = function (event) {
const { origin } = event; const { origin } = event;
// Logger.log('origin', event.origin); // Logger.log('origin', event.origin);
if (origin === 'https://login.dingtalk.com') { if (origin === 'https://login.dingtalk.com') {
...@@ -1214,15 +1231,15 @@ class Login { ...@@ -1214,15 +1231,15 @@ class Login {
if (industry) { if (industry) {
let userInfo = let userInfo =
self.globalConfig.userInfo && self.globalConfig.userInfo &&
self.globalConfig.userInfo.Groups && self.globalConfig.userInfo.Groups &&
self.globalConfig.userInfo.Groups instanceof Array self.globalConfig.userInfo.Groups instanceof Array
? self.globalConfig.userInfo.Groups.find(enter => { ? self.globalConfig.userInfo.Groups.find(enter => {
if (toSite) { if (toSite) {
return enter.site === toSite; return enter.site === toSite;
} else { } else {
return enter.industry === industry; return enter.industry === industry;
} }
}) })
: null; : null;
if (industry === '熊猫新产品' && site) { if (industry === '熊猫新产品' && site) {
...@@ -1245,8 +1262,8 @@ class Login { ...@@ -1245,8 +1262,8 @@ class Login {
site: decodeURIComponent(decode(site)), site: decodeURIComponent(decode(site)),
Groups: Groups:
self.globalConfig.userInfo && self.globalConfig.userInfo &&
self.globalConfig.userInfo.Groups && self.globalConfig.userInfo.Groups &&
self.globalConfig.userInfo.Groups instanceof Array self.globalConfig.userInfo.Groups instanceof Array
? self.globalConfig.userInfo.Groups ? self.globalConfig.userInfo.Groups
: null, : null,
}; };
...@@ -1334,8 +1351,8 @@ class Login { ...@@ -1334,8 +1351,8 @@ class Login {
(response.token (response.token
? response.token ? response.token
: response.access_token !== null && response.user_token !== null : response.access_token !== null && response.user_token !== null
? response.user_token ? response.user_token
: ''); : '');
if (token) { if (token) {
const exp = 86400000; const exp = 86400000;
self.globalConfig.token = token; self.globalConfig.token = token;
...@@ -1384,7 +1401,7 @@ class Login { ...@@ -1384,7 +1401,7 @@ class Login {
} }
} }
login(usr, pwd, userPhone, isRememberPWD, mode = SERVICE_APP_LOGIN_MODE.password, captcha) { login(usr, pwd, userPhone, isRememberPWD, mode = SERVICE_APP_LOGIN_MODE.password, captcha, generateType) {
this.globalConfig = getGlobalConfig(); this.globalConfig = getGlobalConfig();
const self = this; const self = this;
if (window.globalConfig && window.globalConfig.hasGateWay) { if (window.globalConfig && window.globalConfig.hasGateWay) {
...@@ -1399,7 +1416,7 @@ class Login { ...@@ -1399,7 +1416,7 @@ class Login {
: encipher(pwd, this.globalConfig.encrypt).toUpperCase() : encipher(pwd, this.globalConfig.encrypt).toUpperCase()
: '', : '',
type: mode, type: mode,
generateType: params.getParams('generateType') || '', generateType: params.getParams('generateType') || generateType || '',
vcode: captcha, vcode: captcha,
}) })
.then(res => { .then(res => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment