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

fix(lib-classifier): expire classification session IDs #6504

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

eatyourgreens
Copy link
Contributor

@eatyourgreens eatyourgreens commented Nov 28, 2024

  • fix the session ID tests so that they fail properly.
  • fix getSessionID to pass the tests, by expiring a session ID after five minutes of inactivity.
  • refactor generateSessionID so that it generates a session ID.
  • refresh the session TTL whenever an annotation is updated.
  • I added storedSession() and newSession() functions, to make it a little clearer what the code is doing.
  • store/utils/session.js is now an ES module that can be copied straight into PFE. PFE and the monorepo both share the same session_id object in session storage, so the session code has to be synchronised for both repo's.

Please request review from @zooniverse/frontend team or an individual member of that team.

Package

  • lib-classifier

Linked Issue and/or Talk Post

How to Review

All classifications made in a single session should still have the same session ID here. The difference from #6499 is that a new session ID should be generated if you do nothing for 5 minutes. It should be possible to record multiple classification sessions from a single browser session in the same tab.

Checklist

PR Creator - Please cater the checklist to fit the review needed for your code changes.
PR Reviewer - Use the checklist during your review. Each point should be checkmarked or discussed before PR approval.

General

  • Tests are passing locally and on Github
  • Documentation is up to date and changelog has been updated if appropriate
  • You can yarn panic && yarn bootstrap or docker-compose up --build and FEM works as expected
  • FEM works in all major desktop browsers: Firefox, Chrome, Edge, Safari (Use Browserstack account as needed)
  • FEM works in a mobile browser

General UX

Example Staging Project: i-fancy-cats

  • All pages of a FEM project load: Home Page, Classify Page, and About Pages
  • Can submit a classification
  • Can sign-in and sign-out
  • The component is accessible

Bug Fix

  • The PR creator has listed user actions to use when testing if bug is fixed
  • The bug is fixed
  • Unit tests are added or updated

@coveralls
Copy link

coveralls commented Nov 28, 2024

Coverage Status

coverage: 77.798% (-0.02%) from 77.818%
when pulling 509481e on eatyourgreens:fix-session-id
into 9294f0c on zooniverse:master.

- fix the session ID tests so that they fail properly.
- fix `getSessionID` to pass the tests.
- refresh the session TTL whenever an annotation is updated.
- fix `stored.ttl` so that dates are compared as `Date` objects.
- refactor `generateSessionID` to return a session ID.
- update tests for `generateSessionID`.
@eatyourgreens eatyourgreens marked this pull request as ready for review November 28, 2024 08:39
Comment on lines -37 to -38
const { authClient } = getRoot(self)
authClient?.checkBearerToken()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These lines are left over from when I was debugging expired auth sessions in Beyond Borders, a long time ago. I forgot to remove them when I was finished.

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.

Classification session IDs don't expire after 5 minutes of inactivity
2 participants