fix: studio registration using the LMS SSO (#30855)

* fix: studio registration using the LMS SSO

Add the social-core settings:
```
INACTIVE_USER_LOGIN = True
INACTIVE_USER_URL = 'http://localhost:18010'
```

Change the registration link's `next` parameter to trigger SSO login
after the registration.
This commit is contained in:
Eugene Dyudyunov
2022-09-01 18:25:22 +03:00
committed by GitHub
parent a1b43766cd
commit ff33fc1014
5 changed files with 19 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ This test file will test registration, login, activation, and session activity t
import datetime
import time
from unittest import mock
from urllib.parse import quote_plus
from ddt import data, ddt, unpack
from django.conf import settings
@@ -174,10 +175,11 @@ class AuthTestCase(ContentStoreTestCase):
with mock.patch.dict(settings.FEATURES, {"ALLOW_PUBLIC_ACCOUNT_CREATION": allow_account_creation}):
response = self.client.get(reverse('homepage'))
assertion_method = getattr(self, assertion_method_name)
login_url = quote_plus(f"http://testserver{settings.LOGIN_URL}")
assertion_method(
response,
'<a class="action action-signup" href="{}/register?next=http%3A%2F%2Ftestserver%2F">Sign Up</a>'.format
(settings.LMS_ROOT_URL)
f'<a class="action action-signup" href="{settings.LMS_ROOT_URL}/register'
f'?next={login_url}">Sign Up</a>'
)
self.assertContains(
response,

View File

@@ -2686,3 +2686,12 @@ COURSE_LIVE_HELP_URL = "https://edx.readthedocs.io/projects/edx-partner-course-s
COURSE_LIVE_GLOBAL_CREDENTIALS = {}
PERSONALIZED_RECOMMENDATION_COOKIE_NAME = 'edx-user-personalized-recommendation'
######################## Registration ########################
# Social-core setting that allows inactive users to be able to
# log in. The only case it's used is when user registering a new account through the LMS.
INACTIVE_USER_LOGIN = True
# Redirect URL for inactive user. If not set, user will be redirected to /login after the login itself (loop)
INACTIVE_USER_URL = f'http://{CMS_BASE}'

View File

@@ -648,3 +648,5 @@ COURSE_LIVE_GLOBAL_CREDENTIALS["BIG_BLUE_BUTTON"] = {
"SECRET": ENV_TOKENS.get('BIG_BLUE_BUTTON_GLOBAL_SECRET', None),
"URL": ENV_TOKENS.get('BIG_BLUE_BUTTON_GLOBAL_URL', None),
}
INACTIVE_USER_URL = f'http{"s" if HTTPS == "on" else ""}://{CMS_BASE}'

View File

@@ -5,6 +5,7 @@
<%!
from django.conf import settings
from django.utils.translation import gettext as _
from urllib.parse import quote_plus
from openedx.core.djangolib.markup import HTML, Text
%>
@@ -162,7 +163,7 @@
<ul class="list-actions">
<li class="action-item">
<a href="${settings.FRONTEND_REGISTER_URL}?next=${current_url}" class="action action-primary">${_("Sign Up & Start Making Your {platform_name} Course").format(platform_name=settings.PLATFORM_NAME)}</a>
<a href="${settings.FRONTEND_REGISTER_URL}?next=${quote_plus(request.build_absolute_uri(settings.LOGIN_URL))}" class="action action-primary">${_("Sign Up & Start Making Your {platform_name} Course").format(platform_name=settings.PLATFORM_NAME)}</a>
</li>
<li class="action-item">
<a href="${settings.LOGIN_URL}?next=${current_url}" class="action action-secondary">${_("Already have a {studio_name} Account? Sign In").format(studio_name=settings.STUDIO_SHORT_NAME)}</a>

View File

@@ -6,6 +6,7 @@
from django.conf import settings
from django.urls import reverse
from django.utils.translation import gettext as _
from urllib.parse import quote_plus
from cms.djangoapps.contentstore import toggles
from cms.djangoapps.contentstore.utils import get_pages_and_resources_url
from openedx.core.djangoapps.discussions.config.waffle import ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND
@@ -266,7 +267,7 @@
</li>
% if static.get_value('ALLOW_PUBLIC_ACCOUNT_CREATION', settings.FEATURES.get('ALLOW_PUBLIC_ACCOUNT_CREATION')):
<li class="nav-item nav-not-signedin-signup">
<a class="action action-signup" href="${settings.FRONTEND_REGISTER_URL}?next=${current_url}">${_("Sign Up")}</a>
<a class="action action-signup" href="${settings.FRONTEND_REGISTER_URL}?next=${quote_plus(request.build_absolute_uri(settings.LOGIN_URL))}">${_("Sign Up")}</a>
</li>
% endif
<li class="nav-item nav-not-signedin-signin">