react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Exception when login fail on 3.0.0 demo

Open jiafei1986 opened this issue 7 years ago • 3 comments

Hi React-admin team, Thanks for the greatful framework. We just tried the 3.0.0 demo but get an issue with login, Could you help check it? Thank you in advance! What you were expecting:

If user login fail, it should show a message what define in the Promise reject What happened instead:

The application just stuck and there is an error in the browser console Uncaught (in promise) invalid login

Steps to reproduce: Input the username as 'demo001'

Related code: authProvider.js

  • Preferably, a CodeSandbox you can fork this one: https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple
  • A link to a GitHub repo with the minimal codebase to reproduce the issue
login: ({ username }) => {
        localStorage.setItem('username', username);
        // accept all username/password combinations
        if ('demo' !== username) {
            return Promise.reject('invalid login');
        }
        return Promise.resolve();
    },

Other information:

Environment npm 6.4.1 node 10.15.0

  • React-admin version: 3.0.4-alpha
  • Last version that did not exhibit the issue (if applicable): 2.9.6 no issue
  • React version: 16.8.0
  • Browser:
  • Stack trace (in case of a JS error):

jiafei1986 avatar Sep 18 '19 03:09 jiafei1986

Well, In your code your stating that only 'demo' user is allowed. Is normal that you get 'invalid login' trying to login with 'demo001' user.

 // accept all username/password combinations
 if ('demo' !== username) { // <-- Only demo user will successfully login 
     return Promise.reject('invalid login');
 }

WiXSL avatar Sep 19 '19 13:09 WiXSL

Confirmed and reproduced. The custom Login form in the demo doesn't catch auth errors as the default one.

fzaninotto avatar Sep 19 '19 15:09 fzaninotto

Fixed by #3718

fzaninotto avatar Sep 20 '19 07:09 fzaninotto