Amplify-js: Is there a synchronous way to see if the user is authenticated?

Created on 1 Oct 2018  路  6Comments  路  Source: aws-amplify/amplify-js

For my SPA I want to check if the user is authenticated prior to navigating to a route. I understand that CurrentAuthenticatedUser is used for this, but it is promise-based and I have to show a loading gif each time the user navigates (to wait for the promise to resolve).

Is there a synchronous way to check if the user is authenticated so that I don鈥檛 have to show the loading gif each time the user navigates?

Cognito feature-request

All 6 comments

@jrp-23 - We do not have this at the moment, but I am marking this issue as a feature request.

I'm curious to know what is the best way to handle it at the moment. I need to check if the user is authenticated prior to opening a page and redirect otherwise and the promise makes it difficult.

I'm curious to know what is the best way to handle it at the moment. I need to check if the user is authenticated prior to opening a page and redirect otherwise and the promise makes it difficult.

Any progress on this?

I've been struggling with this as well. My application is routing to the Cognito hosted UI for authentication, and it takes 2-3 log in attempts before the Promise gets resolved. This is is a cumbersome user experience, and I can't find a solid non-trivial coding example for how to do this properly.

I'm using Angular 7.2 with Amplify 1.2.22.

Is there any progress on this feature or a recommended workaround?

We need to be able to synchronously check if there is a cached user. It is causing significant issues for us. Thank you for the help.

Yes, there needs to be a synchronous way to check if a user exists in localstorage.
Waiting for promise to be resolved takes time ===> unwanted.

Any help would be appreciated :)

Agree with all the points above 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ldgarcia picture ldgarcia  路  3Comments

shinnapatthesix picture shinnapatthesix  路  3Comments

rygo6 picture rygo6  路  3Comments

guanzo picture guanzo  路  3Comments

benevolentprof picture benevolentprof  路  3Comments