diff --git a/lms/static/js/spec/student_account/login_spec.js b/lms/static/js/spec/student_account/login_spec.js
index e162dc125d..678d1b6b21 100644
--- a/lms/static/js/spec/student_account/login_spec.js
+++ b/lms/static/js/spec/student_account/login_spec.js
@@ -18,6 +18,7 @@
requests = null,
authComplete = false,
PLATFORM_NAME = 'edX',
+ ENTERPRISE_SLUG_LOGIN_URL = 'enterprise/login',
USER_DATA = {
email: 'xsy@edx.org',
password: 'xsyisawesome',
@@ -88,7 +89,8 @@
model: model,
resetModel: resetModel,
thirdPartyAuth: THIRD_PARTY_AUTH,
- platformName: PLATFORM_NAME
+ platformName: PLATFORM_NAME,
+ enterpriseSlugLoginURL: ENTERPRISE_SLUG_LOGIN_URL
});
// Spy on AJAX requests
@@ -198,6 +200,13 @@
expect($('.forgot-password')).toBeVisible();
});
+ it('displays a link to the enterprise slug login', function() {
+ createLoginView(this);
+
+ // Verify that the enterprise login link is displayed
+ expect($('.enterprise-login')).toBeVisible();
+ });
+
it('displays password reset success message after password reset request', function() {
createLoginView(this);
diff --git a/lms/static/js/student_account/views/AccessView.js b/lms/static/js/student_account/views/AccessView.js
index 6e2193618e..1289e73095 100644
--- a/lms/static/js/student_account/views/AccessView.js
+++ b/lms/static/js/student_account/views/AccessView.js
@@ -78,6 +78,7 @@
this.hideAuthWarnings = options.hide_auth_warnings || false;
this.pipelineUserDetails = options.third_party_auth.pipeline_user_details;
this.enterpriseName = options.enterprise_name || '';
+ this.enterpriseSlugLoginURL = options.enterprise_slug_login_url || '';
this.isAccountRecoveryFeatureEnabled = options.is_account_recovery_feature_enabled || false;
this.isMultipleUserEnterprisesFeatureEnabled =
options.is_multiple_user_enterprises_feature_enabled || false;
@@ -160,7 +161,8 @@
createAccountOption: this.createAccountOption,
hideAuthWarnings: this.hideAuthWarnings,
pipelineUserDetails: this.pipelineUserDetails,
- enterpriseName: this.enterpriseName
+ enterpriseName: this.enterpriseName,
+ enterpriseSlugLoginURL: this.enterpriseSlugLoginURL
});
// Listen for 'password-help' event to toggle sub-views
diff --git a/lms/static/js/student_account/views/LoginView.js b/lms/static/js/student_account/views/LoginView.js
index 9997817636..703ed4f6c7 100644
--- a/lms/static/js/student_account/views/LoginView.js
+++ b/lms/static/js/student_account/views/LoginView.js
@@ -23,7 +23,8 @@
events: {
'click .js-login': 'submitForm',
'click .forgot-password': 'forgotPassword',
- 'click .login-provider': 'thirdPartyAuth'
+ 'click .login-provider': 'thirdPartyAuth',
+ 'click .enterprise-login': 'enterpriseSlugLogin'
},
formType: 'login',
requiredStr: '',
@@ -54,6 +55,7 @@
this.hideAuthWarnings = data.hideAuthWarnings;
this.pipelineUserDetails = data.pipelineUserDetails;
this.enterpriseName = data.enterpriseName;
+ this.enterpriseSlugLoginURL = data.enterpriseSlugLoginURL;
this.listenTo(this.model, 'sync', this.saveSuccess);
this.listenTo(this.resetModel, 'sync', this.resetEmail);
@@ -137,6 +139,13 @@
this.clearPasswordResetSuccess();
},
+ enterpriseSlugLogin: function(event) {
+ event.preventDefault();
+ if (this.enterpriseSlugLoginURL) {
+ window.location.href = this.enterpriseSlugLoginURL;
+ }
+ },
+
postFormSubmission: function() {
this.clearPasswordResetSuccess();
},
diff --git a/lms/templates/student_account/form_field.underscore b/lms/templates/student_account/form_field.underscore
index 6350d77bdf..8e6f3713fc 100644
--- a/lms/templates/student_account/form_field.underscore
+++ b/lms/templates/student_account/form_field.underscore
@@ -134,5 +134,6 @@
<% if( form === 'login' && name === 'password' ) { %>
+
<% } %>
diff --git a/openedx/core/djangoapps/user_authn/views/login_form.py b/openedx/core/djangoapps/user_authn/views/login_form.py
index 0d850eae30..f45ecd874b 100644
--- a/openedx/core/djangoapps/user_authn/views/login_form.py
+++ b/openedx/core/djangoapps/user_authn/views/login_form.py
@@ -28,7 +28,8 @@ from openedx.core.djangoapps.user_authn.views.registration_form import Registrat
from openedx.features.enterprise_support.api import enterprise_customer_for_request
from openedx.features.enterprise_support.utils import (
handle_enterprise_cookies_for_logistration,
- update_logistration_context_for_enterprise
+ get_enterprise_slug_login_url,
+ update_logistration_context_for_enterprise,
)
from student.helpers import get_next_url_for_login_page
from third_party_auth import pipeline
@@ -211,7 +212,8 @@ def login_and_registration_form(request, initial_mode="login"):
'account_creation_allowed': configuration_helpers.get_value(
'ALLOW_PUBLIC_ACCOUNT_CREATION', settings.FEATURES.get('ALLOW_PUBLIC_ACCOUNT_CREATION', True)),
'is_account_recovery_feature_enabled': is_secondary_email_feature_enabled(),
- 'is_multiple_user_enterprises_feature_enabled': is_multiple_user_enterprises_feature_enabled()
+ 'is_multiple_user_enterprises_feature_enabled': is_multiple_user_enterprises_feature_enabled(),
+ 'enterprise_slug_login_url': get_enterprise_slug_login_url()
},
'login_redirect_url': redirect_to, # This gets added to the query string of the "Sign In" button in header
'responsive': True,
diff --git a/openedx/features/enterprise_support/utils.py b/openedx/features/enterprise_support/utils.py
index 2e99348cfd..b58d164925 100644
--- a/openedx/features/enterprise_support/utils.py
+++ b/openedx/features/enterprise_support/utils.py
@@ -7,6 +7,7 @@ import json
from crum import get_current_request
from django.conf import settings
+from django.urls import NoReverseMatch, reverse
from django.utils.translation import ugettext as _
from edx_django_utils.cache import TieredCache, get_cache_key
from enterprise.models import EnterpriseCustomerUser
@@ -17,6 +18,7 @@ from lms.djangoapps.branding.api import get_privacy_url
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.user_authn.cookies import standard_cookie_settings
from openedx.core.djangolib.markup import HTML, Text
+from student.helpers import get_next_url_for_login_page
def get_data_consent_share_cache_key(user_id, course_id):
@@ -315,3 +317,28 @@ def is_enterprise_learner(user):
(bool): True if given user is an enterprise learner.
"""
return EnterpriseCustomerUser.objects.filter(user_id=user.id).exists()
+
+
+def get_enterprise_slug_login_url():
+ """
+ Return the enterprise slug login's URL (enterprise/login) if it exists otherwise None
+ """
+ try:
+ return reverse('enterprise_slug_login')
+ except NoReverseMatch:
+ return None
+
+
+def get_provider_login_url(request, provider_id, redirect_url=None):
+ """
+ Return the given provider's login URL.
+
+ This method is here to avoid the importing of pipeline and student app in enterprise.
+ """
+
+ provider_login_url = third_party_auth.pipeline.get_login_url(
+ provider_id,
+ third_party_auth.pipeline.AUTH_ENTRY_LOGIN,
+ redirect_url=redirect_url if redirect_url else get_next_url_for_login_page(request)
+ )
+ return provider_login_url
diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt
index a9e6dc68a4..0d14ff37f3 100644
--- a/requirements/edx/base.txt
+++ b/requirements/edx/base.txt
@@ -103,7 +103,7 @@ edx-django-release-util==0.4.4 # via -r requirements/edx/base.in
edx-django-sites-extensions==2.5.1 # via -r requirements/edx/base.in
edx-django-utils==3.2.2 # via -r requirements/edx/base.in, django-config-models, edx-drf-extensions, edx-enterprise, edx-rest-api-client, edx-when
edx-drf-extensions==6.0.0 # via -r requirements/edx/base.in, edx-completion, edx-enterprise, edx-organizations, edx-proctoring, edx-rbac, edx-when, edxval
-edx-enterprise==3.2.17 # via -r requirements/edx/base.in
+edx-enterprise==3.2.18 # via -r requirements/edx/base.in
edx-i18n-tools==0.5.3 # via ora2
edx-milestones==0.3.0 # via -r requirements/edx/base.in
edx-opaque-keys[django]==2.1.0 # via -r requirements/edx/paver.txt, edx-bulk-grades, edx-ccx-keys, edx-completion, edx-drf-extensions, edx-enterprise, edx-milestones, edx-organizations, edx-proctoring, edx-user-state-client, edx-when, xmodule
diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt
index 9b55bae19e..f83a99546d 100644
--- a/requirements/edx/development.txt
+++ b/requirements/edx/development.txt
@@ -115,7 +115,7 @@ edx-django-release-util==0.4.4 # via -r requirements/edx/testing.txt
edx-django-sites-extensions==2.5.1 # via -r requirements/edx/testing.txt
edx-django-utils==3.2.2 # via -r requirements/edx/testing.txt, django-config-models, edx-drf-extensions, edx-enterprise, edx-rest-api-client, edx-when
edx-drf-extensions==6.0.0 # via -r requirements/edx/testing.txt, edx-completion, edx-enterprise, edx-organizations, edx-proctoring, edx-rbac, edx-when, edxval
-edx-enterprise==3.2.17 # via -r requirements/edx/testing.txt
+edx-enterprise==3.2.18 # via -r requirements/edx/testing.txt
edx-i18n-tools==0.5.3 # via -r requirements/edx/testing.txt, ora2
edx-lint==1.4.1 # via -r requirements/edx/testing.txt
edx-milestones==0.3.0 # via -r requirements/edx/testing.txt
diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt
index 1f264d68f2..513e4127f1 100644
--- a/requirements/edx/testing.txt
+++ b/requirements/edx/testing.txt
@@ -112,7 +112,7 @@ edx-django-release-util==0.4.4 # via -r requirements/edx/base.txt
edx-django-sites-extensions==2.5.1 # via -r requirements/edx/base.txt
edx-django-utils==3.2.2 # via -r requirements/edx/base.txt, django-config-models, edx-drf-extensions, edx-enterprise, edx-rest-api-client, edx-when
edx-drf-extensions==6.0.0 # via -r requirements/edx/base.txt, edx-completion, edx-enterprise, edx-organizations, edx-proctoring, edx-rbac, edx-when, edxval
-edx-enterprise==3.2.17 # via -r requirements/edx/base.txt
+edx-enterprise==3.2.18 # via -r requirements/edx/base.txt
edx-i18n-tools==0.5.3 # via -r requirements/edx/base.txt, -r requirements/edx/testing.in, ora2
edx-lint==1.4.1 # via -r requirements/edx/testing.in
edx-milestones==0.3.0 # via -r requirements/edx/base.txt