MrHertal/react-admin-amplify

cognito keep return no current user

tommy921092 opened this issue · 20 comments

I cloned your demo with amplify init --app 'the link', and after adding the cognito user groups in my aws cognito console, I failed to login and it keeps returns something like 'no current user', failed to get user pool etc...Do you know why it happens? Thanks.

You made me realize that cloning the demo to bootstrap a project is not easy.

I just updated the demo and added some instructions to do that : https://github.com/MrHertal/react-admin-amplify-demo#how-to-clone-this-project

Try to follow these steps and tell me if that worked.

Thanks, it works!
By the way, can you explain the use case for the user page?
I logged in and tried to create a user using superadmin account in the panel, but then the created account is not created in cognito, checking the code in User.js it seems this is not creating a cognito user. Instead it is just creating a user record in dynamodb, is it a left-to-do task?

Yes, you should not care about user and super admin group and you can remove it. I only made this to manage the demo user, who is the user publicly used by everyone to access the demo.

Managing Cognito users from the admin is something I want to add in a future release.

@MrHertal
Thank you for your nice project!
I have same problem in my own react admin project.

I use Amplify/Auth and API, created cognito user group 'admin' and add some demo users to the group.
After that, I start dev server with yarn start and login page keeps returning 'no current user' error with right userName and password.....

How can I fix the error?

function App() {
  return (
    <Admin
      authProvider={buildAuthProvider({ authGroups: ["admin"] })}
      dataProvider={buildDataProvider({ queries, mutations })}
    >
      <Resource name="items" create={ItemCreate} show={ItemShow} edit={ItemEdit} list={ItemList} options={{ authGroups: ["admin"] }}/>
    </Admin>
  );
}

enter the wrong username and password, it returns user does not exist correctly.

window.LOG_LEVEL = 'DEBUG';

and get

スクリーンショット 2021-02-18 12 26 59

Hi @umepon0626

Can you show me the errors returned by Cognito (if there is) in the network tab of your dev tool ?

like this snapshot:

snap

@MrHertal Thank you for responding!!

Sorry, there are no error responses.....

スクリーンショット 2021-02-18 20 23 36

スクリーンショット 2021-02-18 20 25 56

it is the console after I reload login screen

@umepon0626 As I remember this is something related to the cognito group, you may need to add the group first then add group to the user pool, the user may need to be verified. It's a bit tricky.

@tommy921092 Thank you for your comment!!
Yes, I know and I did it. (Sorry for my forgetting letting you know the situation detail...)

スクリーンショット 2021-02-18 22 19 28

スクリーンショット 2021-02-18 22 17 15

Looks like your admin user must change is password before he can sign in

Check that link to set the password with the aws cli: https://stackoverflow.com/a/56948249/4140356

@MrHertal
Thank you!!! I'll try it!

@MrHertal
I did it and succeeded to login!

@MrHertal
I succeeded to login with localhost and after published, I failed login with the same username and password....
Do you have any Idea or solution of this propblem?

スクリーンショット 2021-02-20 22 19 06

This is weird because you got the same challenge than before "PASSWORD_VERIFIER". I think it means that password must be set again...

Are you sure that your user "test" has a password definitely set?

@MrHertal
Yes, I did the same process (make user in console and change password with command line via cli)
スクリーンショット 2021-02-21 9 40 22

@MrHertal I deleted cloudfront cache and this problem solved....