8.15 登录过程中用户信息错误导致登录失败的业务处理

This commit is contained in:
jl-zhoujl2
2022-08-15 09:14:14 +08:00
parent c060f3fa23
commit 3fe854ff86
7 changed files with 85 additions and 59 deletions

View File

@ -1,12 +1,14 @@
import { logoutTokenApi } from '@/services/login';
import { getURLInformation, isNotEmpty } from '@/utils/CommonUtils';
import { getSessionRoleData } from '@/utils/session';
import { Result, Typography } from 'antd';
import { Button, Result, Typography } from 'antd';
import React, { useEffect, useState } from 'react';
import { history } from 'umi';
const message = {
const messageMap = {
401: '您的用户信息有误,请联系管理员',
402: '您的用户角色信息缺失,请联系管理员',
403: '您的用户角色信息异常,请重新登录',
90401: '您的登录已超时,请重新登录',
404: '系统错误,请联系管理员',
};
@ -16,6 +18,7 @@ const RequestTimeoutPage: React.FC<{}> = () => {
const { Text } = Typography;
const [time, setTime] = useState<number>(10);
const roleData = getSessionRoleData();
const token = sessionStorage.getItem('Authorization');
useEffect(() => {
let timeInteval: any
@ -44,11 +47,18 @@ const RequestTimeoutPage: React.FC<{}> = () => {
})
}
}
const redirectLogin = () => {
logoutTokenApi({ mall3_token: token }).then(res => {
history.replace({
pathname: '/userformal/login',
})
})
}
return (
<Result
title={message[code]}
extra={isNotEmpty(roleData) && code == 402 && <Text type="secondary" strong>{time}</Text>}
title={messageMap[code]}
extra={isNotEmpty(roleData) && code == 402 ? <Text type="secondary" strong>{time}</Text> : code == 403 ? <Button type="primary" onClick={() => redirectLogin()}></Button> : null}
/>
);
};