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

clear progress in sessionStorage when signing in via secret pictures or secret words #29386

Merged
merged 3 commits into from Jun 28, 2019

Conversation

davidsbailey
Copy link
Member

@davidsbailey davidsbailey commented Jun 27, 2019

Background

When a signed-out user makes progress, we storage that progress in sessionStorage. When a signed-in user makes progress, we persist that progress in the user_levels table, but we also store it in sessionStorage. We make a best-effort attempt to clear sessionStorage when a user signs in or out, but sometimes we fail to do this, causing progress to leak between users as described in LP-502.

It's not 100% clear why we store progress in sessionStorage. PRs #4256 and #4452 are poorly documented, but it probably had something to do with achieving scalability on HoC scripts.

signing in

On sign-in, we sometimes clear sessionStorage by attaching event handlers to the UI elements used to submit login data:

signing out

On sign-out, we clear session storage when the sign-out menu item is selected. This succeeds when done from dashboard pages, but fails when done from pegasus because sessionStorage is domain-specific:

$('.user_options a:last').click(function (e) {
// this partial can be on non-dashboard pages.
if (typeof dashboard !== 'undefined') {
dashboard.clientState.reset();
} else {
// Keep in sync with clientState#reset.
try {
sessionStorage.clear();

Description

Fixes the specific problem described in LP-502, by making sure we clear sessionStorage when a user signs in via secret pictures or secret words (fd7384c). This ensures we always clear sessionStorage when signing in via the UI, preventing progress from being leaked between signed-in users, or from a signed-out user to a signed-in user. This does NOT prevent progress from being leaked from a signed-in user to a signed-out user in all cases (see Caveats).

Caveats

  1. this solution does not prevent leakage of progress when a user signs out in either of the following ways:
    a. by hitting https://studio.code.org/users/sign_out directly
    b. by using the drop-down menu to sign out from https://code.org/congrats

  2. this solution is brittle because it relies on each sign in / sign out mechanism to remember to clear session storage

Detours

  • extracted sections/show.js from haml in 2270dbb without making any functional changes in that commit

Future Work

A simple, robust solution would be to isolate progress belonging to different users by bucketing sessionStorage progress based on user id. This work item is tracked by LP-576.

Copy link
Contributor

@maddiedierker maddiedierker left a comment

Choose a reason for hiding this comment

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

great investigation and fix! i think your idea for future work sounds good and works really well with our future work to refactor how progress is stored in redux (i.e., store by user_id so we have the ability to store and quarantine separate users' progress info)

@davidsbailey
Copy link
Member Author

Hey Maddie, I assume the goal of the work you're referring to is to let the teacher panel switch between students without reloading the page. Thanks for calling that out!

Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

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

Agreed! Great improvement and detour, and next steps sound exactly correct.

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