I am trying to run the following code, and it always returns "not authenticated' error.
Why this is not working? I would expect, that Auth.currentAuthenticatedUser() runs correctly and returns user object, but it does not.
signIn() {
const { username, password } = this.inputs;
Auth.signIn(username, password)
.then(user => {
Auth.currentAuthenticatedUser()
.then((user) => console.log('user', user)
).catch((err) => console.log('error', err))
}).catch(err => this.error(err));
}
@nomadus You need to check the user's challengeName to see if you need to confirm the user with SNS or email. Mostly it's related to your cognito userpool settings. You may check the code here. Thanks.
@powerful23 Hi, thanks for quick response. I am not sure if I understood you correctly.
The user I am signing in, has already been confirmed, email has been verified. I logged the user, which comes from Auth.SignIn, there is no challengeName attribute.
I had cookieStorage configured in the aws-export.js file, after removing it the error has gone. So the issue can be closed now.
I am also running into this issue.
When I have cookieStorage configured, Auth.currentAuthenticatedUser() and Auth.currentSession() both determine that there is no logged in user. I can successfully login, but after I call either of those functions, they both throw errors stating there is no current user.
However, if I remove the cookieStorage configuration everything works as expected. I can Auth.signIn() successfully, refresh the page, and call Auth.currentAuthenticatedUser() and get the current user.
Is there something different, configuration-wise, when cookieStorage is used?
Related to #812
Most helpful comment
I had cookieStorage configured in the aws-export.js file, after removing it the error has gone. So the issue can be closed now.