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

不能登录的问题

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