Cleanup of third-party login and auto-enrollment - #8262
Conversation
|
Thanks for the pull request, @bradenmacdonald! It looks like you're a member of a company that does contract work for edX. If you're doing this work as part of a paid contract with edX, you should talk to edX about who will review this pull request. If this work is not part of a paid contract with edX, then you should ensure that there is an OSPR issue to track this work in JIRA, so that we don't lose track of your pull request. To automatically create an OSPR issue for this pull request, just visit this link: http://openedx-webhooks.herokuapp.com/github/process_pr?number=8262&repo=edx%2Fedx-platform |
de033b0 to
f38c1de
Compare
|
@bradenmacdonald I had a short look at the code, and did a bit of testing. I'll do a full pass through the code tomorrow. Unfortunately, the fix doesn't seem to work for me. I went to the sandbox, clicked on "Sign in", then on "Dummy", then on "Create an account", entered some data and clicked "Create your account", went to the account settings and scrolled to the bottom. The "Connected Accounts" list shows Dummy with the link "Link" behind it, indicating that the account is not linked yet. Finishing the registration by clicking the activation link in the email doesn't seem to change anything. I also got a few 500s when trying to remove the accounts I added again, but they are likely caused by me creating the superuser the wrong way (using |
|
@smarnach Hmm, I'll look into it. Regarding the 500 errors when deleting users: The behaviour on our sandbox seems different than on devstack. It turns out that you have to delete all the associated UserPreference objects, and then you can delete the user without issue. |
2280746 to
e6dfb4f
Compare
|
@smarnach Ah, turns out a last-minute change I'd made had broken this if you started with the login page rather than the register page I believe I have fixed it now by rewriting the |
|
@bradenmacdonald Thanks, the linking works fine now. After the steps described in my previous comment, "Dummy" is listed with an "Unlink" link after it in the user settings, indicating that linking has worked. However, if I then immediately log out, click "Sign in" and "Dummy" again, nothing happens (well, the page gets reloaded, but that's hardly noticable). After account activation, logging in with the Dummy button works fine. |
|
With |
|
I updated the code on the sandbox and tested the latest fix – works fine. The issue that logging in with Dummy again before activating the account does nothing without giving an error message to the user still remains (but might be considered a different bug outside the scope of this fix). Let me know when this is ready for a final round of testing. |
0dc67b2 to
5e91c58
Compare
d9c85ce to
57045d2
Compare
|
@smarnach Ok, error messages should now be working too. You can test them locally if you disable django debug toolbar. |
ce0a23d to
ef7526c
Compare
|
@bradenmacdonald I tested it again with various settings and login flows, and couldn't find any issues with the latest version. 👍 |
|
Thanks for the pull request, @bradenmacdonald! I've created OSPR-631 to keep track of it in JIRA. JIRA is a place for product owners to prioritize feature reviews by the engineering development teams. Feel free to add as much of the following information to the ticket:
All technical communication about the code itself will still be done via the Github pull request interface. As a reminder, our process documentation is here. |
|
@sarina we still need an accessibility review and agreement on an upgrade strategy from DevOps. |
|
@rlucioni I believe we have already talked about doing the fake migration when it comes time to deploy this code to edx production environments. Is there something more, that I'm not aware of? |
|
Great, thanks @feanil. I was making sure we were all set on that front. @bradenmacdonald and @sarina, all we need before merging this is an accessibility review from @cptvitamin. I'll do my best to help him walk through the changes being made today. |
|
@bradenmacdonald, @rlucioni just walked me through this process and it appears as though the only event that would have an accessibility impact would be the interstitial page that asks a user to "Please wait" Do you agree with that? If so, I think this should be fine. The page's Unless there is some other UI you think I should take a look at. |
|
@bradenmacdonald I'm ready to merge this once you respond to @cptvitamin's comment. |
|
@cptvitamin Yep, I agree that that's the only accessibility impact. Thanks! @rlucioni Please merge away :) Thanks a lot for all your help on this. Do you want [me] to squash this first though? |
|
@rlucioni I confirmed with Nimisha that Mobile is good with this PR. We've got UX and a11y sign off as well. Can you respond to Braden above, and merge when it's looking good to you? Thanks! |
|
Thanks for the follow-up @sarina. @bradenmacdonald yes, please squash your commits. As I said earlier, since your changes require an upgraded version of python-social-auth (which may not be backward-compatible with the old code), I think the version change should be bundled together with your other work. |
cbdb852 to
7255f7d
Compare
|
@rlucioni I fixed the JS issues: The fixes I made are in cbdb8526161b6cf5edcdca5a0403409b3014308d but I subsequently squashed them into the main commit. Please take a quick look at that commit, and then this should be ready to merge. |
7255f7d to
ade6942
Compare
ade6942 to
448c96d
Compare
There was a problem hiding this comment.
@bradenmacdonald why is this being removed? It makes the browser's back button compatible with the logistration page.
There was a problem hiding this comment.
As discussed via chat: JSHint was complaining about this code and it appears to not be doing anything. Let me know if you find out otherwise, and I can revert this since it's mostly an incidental change.
There was a problem hiding this comment.
I did a little more digging into the event handler, and I agree that it's not necessary. getState() doesn't appear to have any side effects.
…ate auto-enrollment code
483f902 to
345fcab
Compare
Cleanup of third-party login and auto-enrollment
|
Thanks Renzo!!! Braden - could you share with me any SSO project plan? (fine to do in On Fri, Jun 19, 2015 at 9:12 AM, Renzo Lucioni notifications@github.com
|
There was a problem hiding this comment.
@bradenmacdonald could you explain why this was removed? FYI @chrisndodge.
There was a problem hiding this comment.
@bradenmacdonald I see that the functionality moved to the auth completion view, which makes sense given your refactor. The question now is why the shoppingcart addition isn't working for @chrisndodge, even though the new code is tested.
There was a problem hiding this comment.
@bradenmacdonald I'm not familiar with the reproduction steps for this issue, but @chrisndodge should have more details.
There was a problem hiding this comment.
@rlucioni EDIT: What I said before didn't really make sense. But yeah, the functionality is available in the auth completion view instead. It says right in the comment that "this elif clause is only used in the "auto-add after user reg/login" case, i.e. it's always wrapped in try_change_enrollment.", and I removed try_change_enrollment.
Can you give me a link to an example on staging or instructions for reproducing the issue?
There was a problem hiding this comment.
Just closing the loop on the added discussion on this PR, post merge. The issue is that there was a change to the JavaScript on the registration page. Since the JavaScript is in the .html template file (rather than a separate .js file), the JS changes have to be also applied to our customers customized registration (it is customized since they have additional signup fields to capture). This has been applied and verified on staging.
As follow-up work, it'd be nice to get the JavaScript out of the the registration.html template and into it's own file at some point.
Description
This is a fix for CRI-9 ("Third party auth association fails to link on login/registration") and ECOM-1503. In order to fix that issue in a clean way, I did some refactoring of parts of the login and auto-enrollment flow.
There were three different parts of the code handling user login and optional auto-enrollment: the old login/register views, the third party auth pipeline, and the new combined "logistration" page. Each of these three had a completely separate implementation for auto-enrolling users into a course following login/registration. Also, none of them correctly completed the third party auth pipeline under all circumstances, meaning that users who do a "social" login often find that their social account never gets linked to their edX account.
Current Situation vs. New Situation
Detailed Description
First, it's important to understand the many different ways that users can login to or register for the LMS:
The code has two significant issues that are addressed by this PR:
try_change_enrollmentandchange_enrollmentin that same file)commerceAPI which in turn uses theenrollmentAPIChanges in this PR:
AccessView.jstoFinishAuthView.js.Benefits of this PR:
/account/finish_auth?course_id=x&enrollment_action=enrollregardless of whether they are logged in or not. Currently the marketing site tracks the user's logged in status and uses different APIs and different logic depending on whether or not the user is logged in. If it did this, there is even more code that could be removed from edX platform, since the login/register pages would no longer need to know about any query string arguments other thannext.Sandbox
Upgrade Issue
When merged, this PR does cause a problem for existing installations:
python-social-authat one point converted fromsyncdbto south/django migrations, and bumping the version ofpython-social-auththat we use will result in this error next timepaver update_dbis run:To fix this (on devstack), the user must manually run this command:
Unfortunately, I'm not aware of any way to avoid this issue other than this manual fix. New installs are not affected.
Screenshots
Testing Instructions
ENABLE_COMBINED_LOGIN_REGISTRATIONin theFEATURESof~/lms.env.json(this change should work whether it's true or false, but each uses different code paths)from django.contrib.auth.models import User; u=User.objects.get(username="Galactica1"); u.is_active=True; u.save())orgcourseandrunwith the values for an actual course on this instance.orgcourseandrunwith the values for a different course on this instance.orgcourseandrunwith the values for a course on this instance.ENABLE_COMBINED_LOGIN_REGISTRATION, restart the server, and repeat the process to test the other views.TODO:
student.views.change_enrollmentin the future (the LMS should use the enrollment API instead for consistency with the login process)Reviewers:
Code: Destination team
Product: Griff, Beth
DevOps: (TBD)