Skip to content

Refresh login page if user logs in on another tab #9797

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

robertknight
Copy link
Member

Add a BroadcastChannel-based mechanism for JS to observe when the user logs into Hypothesis in another tab. This will be used to streamline the process where the user signs up from an auth popup window opened by the Hypothesis client.

It works as follows:

  • In every HTML page, the backend renders a <meta name="userid" ...> tag if the user is logged in.
  • On the frontend, the header script that is included on every page reads this and sends out a notification of the current status via a BroadcastChannel
  • Interested observers in other tabs can listen for events on this channel.

In this proof of concept, the login form auto-refreshes via location.reload() when this happens.

Part of hypothesis/client#7216.

Add a BroadcastChannel-based mechanism for JS to observe when the user
logs into Hypothesis in another tab. This will be used to streamline the
process where the user signs up from an auth popup window opened by the
Hypothesis client.

It works as follows:

 - In every HTML page, the backend renders a `<meta name="userid" ...>`
   tag if the user is logged in.
 - On the frontend, the header script that is included on every page
   reads this and sends out a notification of the current status via a
   `BroadcastChannel`
 - Interested observers in other tabs can listen for events on this
   channel.

In this proof of concept, the login form auto-refreshes via `location.reload()`
when this happens.
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.

1 participant