React-admin: adding authProvider causes infinite loop re-calling checkAuth

Created on 9 Oct 2020  路  2Comments  路  Source: marmelab/react-admin

First of all thanks for the library, it's been great.

I can't seem to figure this error out. If I enable my authProvider, the browsers won't even load as it gets stuck in an infinite loop somehow and I can't figure out where.

What you were expecting:
Providing an authProvider object would call checkAuth, and if that failed, would then call login()

What happened instead:
The page is stuck in a loop which causes the page to never load.

Steps to reproduce:

Related code:

App.js

import React from "react";
import {Admin, Resource} from "react-admin";
import jsonServerProvider from 'ra-data-json-server'
import {UserList, UserEdit, UserCreate} from "./components/Users";
import authProvider from './authProviderTest'
import {
    AccountList,
    AccountShow,
    AccountEdit,
    AccountCreate,
} from "./components/Accounts";
import UserIcon from "@material-ui/icons/Group";
import BusinessIcon from "@material-ui/icons/Business";

const dataProvider = jsonServerProvider('http://localhost:4000')
const App = () => (
    <Admin dataProvider={dataProvider} authProvider={authProvider}>
        <Resource
            name="users"
            list={UserList}
            edit={UserEdit}
            create={UserCreate}
            icon={UserIcon}
        />
        <Resource
            name="accounts"
            list={AccountList}
            show={AccountShow}
            edit={AccountEdit}
            create={AccountCreate}
            icon={BusinessIcon}
        />
        <Resource
            name="permissions"
        />
        <Resource
            name="states"
        />
    </Admin>
);

export default App;

authProviderTest.js

const authProvider = {
        login: params => Promise.resolve(),
        logout: params => Promise.resolve(),
        checkAuth: params => Promise.resolve(),
        checkError: error => Promise.resolve(),
        getPermissions: params => Promise.resolve(),
        getIdentity: () => Promise.resolve(),
    };
export default authProvider

Please find full code here.

Other information:
It appears to be creating multiple checkSession threads in the chrome debugger tools.

Environment
"ra-data-json-server": "^3.9.2",
"ra-data-simple-rest": "^3.9.1",
"react": "^16.13.1",
"react-admin": "^3.9.2",
"react-dom": "^16.13.1",
"react-scripts": "3.4.3"

  • Browser: Chrome
  • Stack trace (in case of a JS error):
bug

Most helpful comment

Reproduced, thanks for the report. Until the fix is released, you can remove the getIdentity method from your authProvider.

All 2 comments

Downgrading to version 3.9.0 worked for me.

Reproduced, thanks for the report. Until the fix is released, you can remove the getIdentity method from your authProvider.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

9747749366 picture 9747749366  路  3Comments

rkyrychuk picture rkyrychuk  路  3Comments

nicgirault picture nicgirault  路  3Comments

yangjiamu picture yangjiamu  路  3Comments

marknelissen picture marknelissen  路  3Comments