Amplify-js: signOut does not work in the browser

Created on 9 Apr 2018  路  9Comments  路  Source: aws-amplify/amplify-js

Do you want to request a feature or report a bug?

bug

What is the current behavior?

signOut does not work in the browser
https://aws.github.io/aws-amplify/media/authentication_guide.html#sign-out

What is the expected behavior?
The expected behavior is that after signOut(), currentSession() returns null or undefined.
This is working correctly on React Native, tested OK on Android and iOS.

Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions?

Amplify version is "aws-amplify": "^0.2.9"

In the browser, when running the following code in Auth.js line 669:
if (source === 'aws' || source === 'userPool') {
source value is ''.

Forcing source value to 'aws' in the console- with a breakpoint on this line- leads to signOut done correctly.

Affected browser is - at least- Chrome 65.0.3325.181

Auth investigating

Most helpful comment

Same - the tokens, etc. are not cleared from localStorage when calling Auth.signout()

Replacing Auth.signOut() with this does work as expected:

const currentUser = Auth.userPool.getCurrentUser()
await currentUser.signOut()

aws-amplify 0.3.0

All 9 comments

@omatrot how did you SignIn via API or via Authenticator? Can you add a debug log as well i.e. Amplify.Logger.LOG_LEVEL="debug"

@mlabieniec Id did SignIn via API.
I'll add debug log tonight.

Amplify version is 0.2.14. Reverting to 0.2.11 (my previously used version) fixes the problem.

Same issue is happening to me. Unfortunately setting LOG_LEVEL does not appear to do anything. I've tried both window.LOG_LEVEL = 'debug' and Amplify.Logger.LOG_LEVEL = 'debug' before and after configuring Amplify and nothing seems to affect the logger used in Auth, which still shows up as ConsoleLogger聽{name: "AuthClass", level: "WARN"}.

As reported in this issue, the value for this.credentials_source is '' so case 3 does not run and user.signOut is never called:

                    case 3:
                        source = this.credentials_source;
                        if (source === 'aws' || source === 'userPool') {
                            if (!this.userPool) {
                                return [2 /*return*/, Promise.reject('No userPool')];
                            }
                            user = this.userPool.getCurrentUser();
                            if (user) {
                                logger.debug('user sign out', user);
                                user.signOut();
                            }
                        }

Setting a breakpoint in case 3 and running this.userPool.getCurrentUser() returns the current user and running this.userPool.getCurrentUser().signOut() completes the sign out as expected.

I sign in via Auth.signIn().

@mlabieniec Nothing to add, then. This is it.

Same - the tokens, etc. are not cleared from localStorage when calling Auth.signout()

Replacing Auth.signOut() with this does work as expected:

const currentUser = Auth.userPool.getCurrentUser()
await currentUser.signOut()

aws-amplify 0.3.0

closing this as this should be fixed in #700

@tunecrew
Works nicely, thank you.

@powerful23 This still doesn't seem to work. I was able to use the solution from tunecrew above for now.

Calling Auth.configure() seemed to return a valid configuration object. Calling Auth.signOut said there was no userPool in undefined, breaking in case 3 mentioned in pbeshai's comment.

@roblingle is this happening in the latest version of amplify? If is, then please open an issue in the repo and we can investigate into it. Thanks!

Was this page helpful?
0 / 5 - 0 ratings