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

[CORL-3008] when auth token is invalid, clear it and reload the stream #4472

Merged
merged 3 commits into from
Jan 11, 2024

Conversation

nick-funk
Copy link
Contributor

What does this PR do?

Makes it so that the stream clears the user's auth token when it is invalid or expired and reloads the stream so they can view comments, log in again, and continue using Coral.

These changes will impact:

  • commenters
  • moderators
  • admins
  • developers

What changes to the GraphQL/Database Schema does this PR introduce?

None

Does this PR introduce any new environment variables or feature flags?

No

If any indexes were added, were they added to INDEXES.md?

No new indices

How do I test this PR?

  • Start up npm run watch on both server and client
  • Login to the stream at http://localhost:8080 with a user account
  • Stop the Coral server watch task (shut down the server)
  • Delete your coral database in Mongo
  • Start up the server with npm run start:development
  • Install a new tenant at http://localhost:3000/install
  • Stop the server again
  • Resume npm run watch for the server
  • Navigate to http://localhost:8080
  • See that the stream obliterates the coral:v2:accessToken storage key and the stream shows up in the signed out state

Were any tests migrated to React Testing Library?

No

How do we deploy this PR?

No special considerations.

@nick-funk nick-funk requested a review from kabeaty December 22, 2023 13:10
Copy link

netlify bot commented Dec 22, 2023

Deploy Preview for gallant-galileo-14878c canceled.

Name Link
🔨 Latest commit 4b16a9e
🔍 Latest deploy log https://app.netlify.com/sites/gallant-galileo-14878c/deploys/659448e44d44bd0008cde477

Copy link
Contributor

@kabeaty kabeaty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Approving, with 2 small comments.

@@ -111,6 +111,8 @@ interface CreateContextArguments {
* of the render window
*/
customScrollContainer?: HTMLElement;

onAuthError?: () => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a comment here explaining onAuthError, consistent with other args?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup!

@@ -99,6 +102,13 @@ export async function attach(options: AttachOptions) {
await new Promise((resolve) => options.refreshAccessToken!(resolve));
}

const onContextAuthError = async () => {
const localStorage = resolveStorage("localStorage");
await localStorage.removeItem("v2:accessToken");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be updated to also use the ACCESS_TOKEN_KEY already defined in client framework?

@nick-funk nick-funk added this pull request to the merge queue Jan 11, 2024
Merged via the queue into develop with commit 5940b09 Jan 11, 2024
6 checks passed
@nick-funk nick-funk deleted the spike/graceful-auth-expiry branch January 11, 2024 20:01
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.

2 participants