Commit d1cb1de9 authored by 杨思琦's avatar 杨思琦

fix: 免登修改

parent b9465cdf
Pipeline #73670 passed with stages
......@@ -23,12 +23,10 @@ const Login = forwardRef((props, _ref) => {
const param = params.getParams('token')?.replaceAll(';', '&');
return param ? decodeURIComponent(escape(param)) : null;
});
const [authCode] = useState(() => {
const param = params.getParams('authCode')?.replaceAll(';', '&');
return param ? decodeURIComponent(escape(param)) : null;
});
// 需要在 GetGateWay 和 GetConfig 之后再执行登录。避免信息错落乱
const hasLogin = useRef();
useEffect(() => {
......@@ -40,56 +38,40 @@ const Login = forwardRef((props, _ref) => {
hasLogin.current !== true &&
window.hasLogin !== true
) {
appService
.checkFreeLogin({
token,
authCode,
})
.then(response => {
if (response?.data) {
hasLogin.current = true;
window.hasLogin = true;
if (window.globalConfig && window.globalConfig.hasGateWay) {
appService
.authorizationToken({
loginName: token,
type: 'token',
generateType: params.getParams('generateType') || '',
})
.then(res => {
if (res.code === 0) {
const { data } = res;
props.updateConfig &&
props.updateConfig(
Object.assign({}, window.globalConfig, {
access_token: data.access_token,
token: data.user_token,
}),
);
return data;
}
message.error({
duration: 3,
content: `授权失败:${res.msg}`,
});
action && action.events.emit('loginError', res.msg);
return Promise.reject(res);
})
.then(res => {
action.transformLoginHander(res, false);
});
} else {
action.init();
hasLogin.current = true;
window.hasLogin = true;
if (window.globalConfig && window.globalConfig.hasGateWay) {
appService
.authorizationToken({
loginName: token,
type: 'token',
generateType: params.getParams('generateType') || '',
})
.then(res => {
if (res.code === 0) {
const { data } = res;
props.updateConfig &&
props.updateConfig(
Object.assign({}, window.globalConfig, {
access_token: data.access_token,
token: data.user_token,
}),
);
return data;
}
return response?.data;
}
message.error({
duration: 3,
content: `授权失败`,
message.error({
duration: 3,
content: `授权失败:${res.msg}`,
});
action && action.events.emit('loginError', res.msg);
return Promise.reject(res);
})
.then(res => {
action.transformLoginHander(res, false);
});
action && action.events.emit('loginError', '授权失败');
return Promise.reject(response);
});
} else {
action.init();
}
}
}, [action, action.globalConfig, props.global]);
......
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