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

Redirect user when loading class summary results in 403 #12755

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

nucleogenesis
Copy link
Member

@nucleogenesis nucleogenesis commented Oct 25, 2024

Summary

When a coach is doing coach things and they are logged out due to timeout, Kolibri will keep track of the last place the user was in. If a coach is doing coach things, then they timeout, but then a Learner logs in again the Learner is redirected to where the coach previously was.

Since the Learner cannot do Coach things, they get a 403 on the classSummary API call.

So we catch that particular error and redirect the user such that they go to wherever they'd normally have gone after logging in.

References

Fixes #12442

Reviewer guidance

  • Sign in as admin/coach and go to create a quiz
  • Go to your devtools and delete the kolibri cookie, see that you are redirected to the sign-in page
  • Sign in as a learner

Before the fix:

  • The learner would see a blank screen and basically be stuck there

After the fix:

  • The learner is completely virtually unaware that they were initially being redirected to Coach things (unless they're keenly watching the URL bar or their devtools as they are still directed to the Coach URL before being re-redirected)

Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@github-actions github-actions bot added APP: Coach Re: Coach App (lessons, quizzes, groups, reports, etc.) DEV: frontend labels Oct 25, 2024
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

This is a fairly drastic change in existing behaviour. The issue asked for the authentication wrapper to be used in the quiz creation flow, not to globally alter behaviour on permission failure.

// done to gracefully handle the case that an admin is signed out due to
// timeout while in Coach and when a Learner signs in, they are returned
// to the URL the admin was previously on and hit this 403
redirectBrowser();
Copy link
Member

Choose a reason for hiding this comment

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

This is not fixing the issue as described - the mismatch in the behaviour was specifically in the quiz creation page, where it is not using the authentication wrapper component to show meaningful errors to the user in the case that they are not authenticted.

Also, as this is now applying to every page in coach, the existing authentication wrapper errors may not show because of this.

Further, if a coach's session expired, and the classSummary API update call returned early, they would now get redirected to the login page, but without a next parameter to guide them back to where they were before.

@nucleogenesis nucleogenesis force-pushed the 0.17--quiz-routing-auth-error branch from b11c898 to c8a6c37 Compare October 25, 2024 22:36
@rtibbles rtibbles dismissed their stale review October 28, 2024 20:35

This looks like the right fix.

@radinamatic
Copy link
Member

Learner is still being stuck with blank page and 403 in the console 😕
(Firefox on Ubuntu)

PR-12755.mp4

@rtibbles
Copy link
Member

Hrm, looks like it's maybe a race condition? If the class notifications endpoint gives a 403 before the class summary endpoint, we see it stuck, but if the class summary endpoint returns then we see the authentication message properly?

@nucleogenesis nucleogenesis changed the base branch from release-v0.17.x to develop October 29, 2024 15:45
@rtibbles rtibbles added the DEV: Core JS API Changes related to, or to the Core JS API label Nov 5, 2024
@rtibbles rtibbles self-assigned this Nov 8, 2024
@nucleogenesis nucleogenesis force-pushed the 0.17--quiz-routing-auth-error branch from 63243b0 to 3eaa320 Compare November 27, 2024 19:36
@nucleogenesis
Copy link
Member Author

@radinamatic I've updated this PR and tested in coach - the learner user should be navigated to the AuthMessage as expected now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APP: Coach Re: Coach App (lessons, quizzes, groups, reports, etc.) DEV: Core JS API Changes related to, or to the Core JS API DEV: frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quiz creation does not properly show the authentication wrapper
4 participants