Skip to content

[BB-1504] Fix the automatic enrollment issue for inactive user - #21594

Merged
ormsbee merged 1 commit into
openedx:masterfrom
open-craft:guruprasad/fix-non-activated-users-can-access-enrolled-courses
Oct 7, 2020
Merged

[BB-1504] Fix the automatic enrollment issue for inactive user#21594
ormsbee merged 1 commit into
openedx:masterfrom
open-craft:guruprasad/fix-non-activated-users-can-access-enrolled-courses

Conversation

@lgp171188

@lgp171188 lgp171188 commented Sep 7, 2019

Copy link
Copy Markdown
Contributor

When a user registers an account and then is enrolled in a course by the instructor before completing the email validation, the course shows up in the dashboard of the unverified, logged-in user. This contrasts with the behavior observed when the user is enrolled before the account is created - the user is unable to see the enrolled course before verifying the email address.

This PR adds a check for the email validation before enrolling the user.

JIRA tickets: OSPR-3832
Dependencies: None
Sandbox URL: https://pr21594.sandbox.opencraft.hosting/
Merge deadline: None

Testing instructions:

  1. Register and create a new account in the LMS. Do not verify the email address.
  2. Stay logged in as that user.
  3. Enroll the user created in the previous step, in a course via the Instructor dashboard in a separate, isolated browser session.
  4. Refresh the dashboard of the logged-in user with unverified email address. Without the fix, the enrolled course shows up in the user's dashboard . With the fix, the course shows up in the unverified user's dashboard only after the email verification is done.

While the unverified user can still navigate to the public courses and enroll, this issue breaks the expected behaviour with invitation-only (and optionally, private) courses.

Reviewers

@lgp171188
lgp171188 requested a review from a team September 7, 2019 12:30
@openedx-webhooks

openedx-webhooks commented Sep 7, 2019

Copy link
Copy Markdown

Thanks for the pull request, @lgp171188! I've created OSPR-3832 to keep track of it in JIRA, where we prioritize reviews. Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@openedx-webhooks openedx-webhooks added needs triage open-source-contribution PR author is not from Axim or 2U labels Sep 7, 2019
@Agrendalath

Copy link
Copy Markdown
Member

@lgp171188, could you please add a point info about disabling AUTOMATIC_AUTH_FOR_TESTING to the testing instructions? It's useful for testing this on the devstack.

👍

  • I tested this: tested this PR on the devstack
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

@natabene

natabene commented Sep 9, 2019

Copy link
Copy Markdown
Contributor

@lgp171188 Thank you for your contribution. Please let me know once it is ready for our review.

@openedx-webhooks openedx-webhooks added waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. and removed needs triage labels Sep 9, 2019
@Agrendalath

Copy link
Copy Markdown
Member

@natabene, this is ready for your review :)

@natabene

natabene commented Sep 9, 2019

Copy link
Copy Markdown
Contributor

@ormsbee This is ready for your review when you have a chance.

@natabene
natabene requested a review from ormsbee September 9, 2019 19:27
@openedx-webhooks openedx-webhooks added awaiting prioritization and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Sep 9, 2019
@lgp171188

Copy link
Copy Markdown
Contributor Author

@ormsbee, did you get a chance to check this?

@lgp171188

Copy link
Copy Markdown
Contributor Author

@ormsbee, did you get a chance to check this out?

1 similar comment
@lgp171188

Copy link
Copy Markdown
Contributor Author

@ormsbee, did you get a chance to check this out?

@natabene

Copy link
Copy Markdown
Contributor

@lgp171188 Sorry, we don't have bandwidth right now. Please coordinate with @pomegranited

@giovannicimolin

Copy link
Copy Markdown
Contributor

jenkins run all

@lgp171188
lgp171188 force-pushed the guruprasad/fix-non-activated-users-can-access-enrolled-courses branch from 353087a to c6bf24d Compare April 3, 2020 17:32
Comment thread lms/djangoapps/instructor/tests/test_enrollment.py Outdated
@lgp171188

Copy link
Copy Markdown
Contributor Author

@bradenmacdonald, since you already left a review comment, I wanted to know if you will be reviewing this PR as a part of your core committer role.

@bradenmacdonald

Copy link
Copy Markdown
Contributor

@bradenmacdonald, since you already left a review comment, I wanted to know if you will be reviewing this PR as a part of your core committer role.

I don't have time for this one right now but was considering it. I may be able to review it in the future.

@lgp171188
lgp171188 force-pushed the guruprasad/fix-non-activated-users-can-access-enrolled-courses branch from c6bf24d to 92793fd Compare September 23, 2020 18:20
@lgp171188

Copy link
Copy Markdown
Contributor Author

@bradenmacdonald, I have updated the PR and the CI checks are now passing. The sandbox mentioned in the PR description has the latest changes from this PR and can be used to verify the fix.

@bradenmacdonald

Copy link
Copy Markdown
Contributor

Thanks @lgp171188 ! Hoping to get to this tomorrow.

@bradenmacdonald bradenmacdonald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 Thanks for this fix, and for the sandbox. Approving but had a couple minor questions.

  • I tested this:

https://pr25142.sandbox.opencraft.hosting/ (without fix)

⚫ Created account user+exists@opencraft.com (did not verify email)
⚫ As staff, invited user+exists@opencraft.com and user+future@opencraft.com to an invite-only course

⚫ Noted that email to user+exists says "You have been enrolled in Private Course"
✅ Confirmed user+exists@opencraft.com is now enrolled, can see the course

⚫ Created account user+future@opencraft.com (did not verify email)
✅ Confirmed user+future@opencraft.com is not enrolled, cannot see the course
⚫ Activated user+future@opencraft.com's account - ✅ confirmed that the course now shows up

https://pr21594.sandbox.opencraft.hosting/ (with this fix)

⚫ Created account user+exists@opencraft.com (did not verify email)
⚫ As staff, invited user+exists@opencraft.com and user+future@opencraft.com to an invite-only course

✅ Confirmed email to both now says "Please finish your registration... Once you have registered and activated your account, you will see Super Secret Private Course listed on your dashboard."
✅ Confirmed user+exists@opencraft.com is not yet enrolled, cannot even log in again until verifying email.
⚫ Activated user+exists@opencraft.com's account - ✅ confirmed that the course now shows up

⚫ Created account user+future@opencraft.com (did not verify email)
✅ Confirmed user+future@opencraft.com is not enrolled, cannot see the course
⚫ Activated user+future@opencraft.com's account - ✅ confirmed that the course now shows up


Note that cases where "a user registers an account and then is enrolled in a course by the instructor before completing the email validation" should be relatively rare, while cases where "the user is enrolled before the account is created" should be more common, so this is bringing the edge case in line with the more common (and secure) behavior.

  • I read through the code
  • I checked for accessibility issues: n/a
  • Includes documentation: n/a

Comment thread lms/djangoapps/instructor/enrollment.py Outdated
Comment thread lms/djangoapps/instructor/tests/test_enrollment.py Outdated
When a user registers an account and is enrolled in a course by the
instructor before completing the email validation, the course shows up
in the dashboard of the logged-in user. This change adds a check for
the email validation before enrolling the user.
@lgp171188
lgp171188 force-pushed the guruprasad/fix-non-activated-users-can-access-enrolled-courses branch from 92793fd to ba5c5e0 Compare October 2, 2020 15:02
@edx-status-bot

Copy link
Copy Markdown

Your PR has finished running tests. There were no failures.

@ormsbee
ormsbee merged commit 5fbc501 into openedx:master Oct 7, 2020
@openedx-webhooks

Copy link
Copy Markdown

@lgp171188 🎉 Your pull request was merged!

Please take a moment to answer a two question survey so we can improve your experience in the future.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

@Agrendalath
Agrendalath deleted the guruprasad/fix-non-activated-users-can-access-enrolled-courses branch October 8, 2020 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants