Commit ec22e5ce authored by 徐乐's avatar 徐乐

feat: 新增单点登录第三方免密跳转

parent 50e58463
Pipeline #83152 passed with stages
......@@ -14,6 +14,7 @@ instanceRequest.transformRequestURL = function(url) {
'/PandaEnergy/WaterSaving/download',
'/PandaOMS/OMS/WebSite/GetConfig',
'/PandaOMS/OMS/CheckFreeLogin',
'/PandaCore/GCK/BussinessAuth/HDAuthLogin',
];
if (excludeURL.includes(url)) {
return url.replace(/PandaCore\/GateWay\//, '');
......
......@@ -20,6 +20,7 @@ export const API = {
GET_WEATHER: '/CityInterface/rest/services/CountyProduct.svc/GetWeather',
SEND_MESSAGE_CODE: 'CityInterface/rest/services/portal.svc/SendMessVerificationCode',
CHANGE_PASSWORD: 'cityinterface/rest/services.svc/changepassword',
HD_AUTH_LOGIN: '/PandaCore/GCK/BussinessAuth/HDAuthLogin',
IOT_CHANGE_PASSWORD: 'CityInterface/rest/services/OMS.svc/U_UpdatePasswordQuickGCK',
FILE_DOWNLOAD: '/cityinterface/rest/services/filedownload.svc/download',
UPDATE_AVATAR: '/CityInterface/rest/services/OMs.svc/U_EditUser',
......@@ -66,6 +67,11 @@ const services = {
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
HDAuthLogin: {
url: API.HD_AUTH_LOGIN,
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
authorizationToken: {
url: API.AUTHORIZATION_TOKEN,
method: constants.REQUEST_METHOD_GET,
......@@ -152,8 +158,8 @@ const services = {
generateToken: {
url: () =>
window.globalConfig &&
(window.globalConfig.loginTemplate === 'Dark - IOTMultiLogin.html' ||
window.globalConfig.loginTemplate === '新春 - 智联.html')
(window.globalConfig.loginTemplate === 'Dark - IOTMultiLogin.html' ||
window.globalConfig.loginTemplate === '新春 - 智联.html')
? API.GENERATE_IOT_TOKEN
: API.GENERATE_TOKEN,
method: constants.REQUEST_METHOD_GET,
......@@ -162,8 +168,8 @@ const services = {
changePassword: {
url: () =>
window.globalConfig &&
(window.globalConfig.loginTemplate === 'Dark - IOTMultiLogin.html' ||
window.globalConfig.loginTemplate === '新春 - 智联.html')
(window.globalConfig.loginTemplate === 'Dark - IOTMultiLogin.html' ||
window.globalConfig.loginTemplate === '新春 - 智联.html')
? API.IOT_CHANGE_PASSWORD
: API.CHANGE_PASSWORD,
method: constants.REQUEST_METHOD_GET,
......
......@@ -31,6 +31,17 @@ class Login {
props.updateConfig(config);
this.globalConfig = getGlobalConfig();
};
//单点登录_xule_20231214
let queryString = window.location.search.substring(1);
let params = queryString.split("&");
let paramsFind = params && params.find(function (a) { return a.split('=')[0] == 'uniwater_utoken' });
this.uniwater_utoken = paramsFind?.split('=')[1] ?? '';
if (this.uniwater_utoken) {
this.getTokenForThird();
}
this.createContext = props.createContext;
this.history = props.history;
this.callback = callback;
......@@ -42,6 +53,73 @@ class Login {
}
}
//单点登录接口_xule_20231214
getTokenForThird() {
let self = this;
appService
.HDAuthLogin({
token: self.uniwater_utoken,
ignoreSite: true,
})
.then(res => {
if (res.success === 'OK') {
const tk = res.token;
self.globalConfig.token = tk;
getUserInfo(
{
token: tk,
subOID: 'subOID',
site: this.getLocalSiteBytoken(tk),
ignoreSite: true,
},
)
.then(response => {
try {
if (response && response.code === 0) {
self.globalConfig.userInfo = window?.globalConfig?.transformUserInfo?.(response.data) ?? {};
const date = new Date();
date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
// date = date.toGMTString();
const encodeSite = encode(encodeURIComponent(response.site));
Cookies.set('site', encodeSite, {
expires: date,
path: '/',
});
Cookies.set('token', tk, {
expires: date,
path: '/',
});
self.isSignIn = true;
self.updateConfig && self.updateConfig(self.globalConfig);
const loginSite = {};
loginSite[tk] = response.site;
localStorage.setItem('loginSite', JSON.stringify(loginSite));
self.writeLogs();
self.getIndustry(false, tk);
} else {
message.error(response.errMsg);
if (self.goLogin()) {
return false;
}
}
self.updateConfig && self.updateConfig(self.globalConfig);
} catch (error) {
message.error('登录失败');
if (self.goLogin()) {
return false;
}
}
})
.catch(error => {
this.handleLoginError();
Logger.log('获取用户配置失败');
});
}
})
}
gzlogin(userPhone) {
this.login(userPhone, '', userPhone, false, SERVICE_APP_LOGIN_MODE.phone);
}
......
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