Commit 2d57d0db authored by 沈翠玲's avatar 沈翠玲

不能登录的问题

parent 127e9578
......@@ -7,7 +7,7 @@ export default function access(initialState: {
}) {
const { currentUser, permissions } = initialState || {};
return {
canAdmin: currentUser && currentUser.roles.some((r) => r === 'admin'),
canAdmin: currentUser && currentUser.roles && currentUser.roles.some((r) => r === 'admin'),
grantAccess: (accessCode: string) => {
return true;
},
......
......@@ -189,9 +189,15 @@ export async function getInitialState(): Promise<{
const fetchUserInfo = async () => {
try {
const msg = await queryCurrentUser();
return msg;
console.log('msgmsg', msg)
if (msg && msg.code === 200) {
return msg;
} else {
history.push(loginPath);
}
} catch (error) {
history.push(loginPath);
history.push(loginPath);
}
return undefined;
};
......
......@@ -53,7 +53,7 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
const { currentUser } = initialState;
if (!currentUser || !currentUser.user.nickName) {
if (!currentUser || !currentUser.user || !currentUser.user.nickName) {
return loading;
}
......
......@@ -86,6 +86,7 @@ declare namespace Api {
type CurrentUser = {
user: any;
roles: any[];
code: number;
};
type CurrentAccount = {
......
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