Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use localStorage to manage the authentication status if the user #405

Merged
merged 11 commits into from Mar 12, 2019

Conversation

jgreben
Copy link
Contributor

@jgreben jgreben commented Mar 11, 2019

Fixes #316

On the HomePage it checks whether the user is authenticated in redux; if not, it will look for the JWT query param and authenticate them. When the component updates it will then save the authentication state to localStorage via the saveState() call.

The LoginPanel, Editor, and other child components then look for the authentication state via the loadState() call and set their local state accordingly.

The HomePage logOut() function gets passed to the LoginPanel child component (other child components will need it later) and when called it clears the localStorage state and then redirects to cognito for the destruction of the JWT.

@jermnelson
Copy link
Contributor

LGTM; one question, is there a way to set a timeout for the jwtAuth stored in LocalStorage?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.9%) to 79.132% when pulling c48debb on store-jwt into 0db4552 on master.

@jgreben
Copy link
Contributor Author

jgreben commented Mar 12, 2019

@jermnelson I added a timeout check to localStorage.js. When the loadState() function is checked, it will return undefined if the timeout set in the jwtAuth hash has passed .

@jermnelson jermnelson merged commit 178db37 into master Mar 12, 2019
@jermnelson jermnelson deleted the store-jwt branch March 12, 2019 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants