Merge pull request #15017 from edx/mattdrayer/ENT-328
mattdrayer/ENT-328: Update account activation message on sign-in form.
This commit is contained in:
@@ -90,7 +90,10 @@ from lms.envs.common import (
|
||||
FILE_UPLOAD_STORAGE_PREFIX,
|
||||
|
||||
COURSE_ENROLLMENT_MODES,
|
||||
|
||||
HELP_TOKENS_BOOKS,
|
||||
|
||||
SUPPORT_SITE_LINK,
|
||||
)
|
||||
from path import Path as path
|
||||
from warnings import simplefilter
|
||||
|
||||
@@ -126,7 +126,7 @@ class LoginTest(CacheIsolationTestCase):
|
||||
# Should now be unable to login
|
||||
response, mock_audit_log = self._login_response('test@edx.org', 'test_password')
|
||||
self._assert_response(response, success=False,
|
||||
value="Before you sign in, you need to activate your account")
|
||||
value="In order to sign in, you need to activate your account.")
|
||||
self._assert_audit_log(mock_audit_log, 'warning', [u'Login failed', u'Account not active for user'])
|
||||
|
||||
@patch.dict("django.conf.settings.FEATURES", {'SQUELCH_PII_IN_LOGS': True})
|
||||
@@ -138,7 +138,7 @@ class LoginTest(CacheIsolationTestCase):
|
||||
# Should now be unable to login
|
||||
response, mock_audit_log = self._login_response('test@edx.org', 'test_password')
|
||||
self._assert_response(response, success=False,
|
||||
value="Before you sign in, you need to activate your account")
|
||||
value="In order to sign in, you need to activate your account.")
|
||||
self._assert_audit_log(mock_audit_log, 'warning', [u'Login failed', u'Account not active for user'])
|
||||
self._assert_not_in_audit_log(mock_audit_log, 'warning', [u'test'])
|
||||
|
||||
@@ -408,7 +408,7 @@ class LoginTest(CacheIsolationTestCase):
|
||||
|
||||
if value is not None:
|
||||
msg = ("'%s' did not contain '%s'" %
|
||||
(str(response_dict['value']), str(value)))
|
||||
(unicode(response_dict['value']), unicode(value)))
|
||||
self.assertIn(value, response_dict['value'], msg)
|
||||
|
||||
def _assert_audit_log(self, mock_audit_log, level, log_strings):
|
||||
|
||||
@@ -1236,6 +1236,39 @@ def change_enrollment(request, check_access=True):
|
||||
return HttpResponseBadRequest(_("Enrollment action is invalid"))
|
||||
|
||||
|
||||
def _generate_not_activated_message(user):
|
||||
"""
|
||||
Generates the message displayed on the sign-in screen when a learner attempts to access the
|
||||
system with an inactive account.
|
||||
|
||||
Arguments:
|
||||
user (User): User object for the learner attempting to sign in.
|
||||
"""
|
||||
|
||||
support_url = configuration_helpers.get_value(
|
||||
'SUPPORT_SITE_LINK',
|
||||
settings.SUPPORT_SITE_LINK
|
||||
)
|
||||
|
||||
platform_name = configuration_helpers.get_value(
|
||||
'PLATFORM_NAME',
|
||||
settings.PLATFORM_NAME
|
||||
)
|
||||
|
||||
not_activated_msg_template = _('In order to sign in, you need to activate your account.<br /><br />'
|
||||
'We just sent an activation link to <strong>{email}</strong>. If '
|
||||
'you do not receive an email, check your spam folders or '
|
||||
'<a href="{support_url}">contact {platform} Support</a>.')
|
||||
|
||||
not_activated_message = not_activated_msg_template.format(
|
||||
email=user.email,
|
||||
support_url=support_url,
|
||||
platform=platform_name
|
||||
)
|
||||
|
||||
return not_activated_message
|
||||
|
||||
|
||||
# Need different levels of logging
|
||||
@ensure_csrf_cookie
|
||||
def login_user(request, error=""): # pylint: disable=too-many-statements,unused-argument
|
||||
@@ -1456,11 +1489,10 @@ def login_user(request, error=""): # pylint: disable=too-many-statements,unused
|
||||
AUDIT_LOG.warning(u"Login failed - Account not active for user {0}, resending activation".format(username))
|
||||
|
||||
reactivation_email_for_user(user)
|
||||
not_activated_msg = _("Before you sign in, you need to activate your account. We have sent you an "
|
||||
"email message with instructions for activating your account.")
|
||||
|
||||
return JsonResponse({
|
||||
"success": False,
|
||||
"value": not_activated_msg,
|
||||
"value": _generate_not_activated_message(user),
|
||||
}) # TODO: this should be status code 400 # pylint: disable=fixme
|
||||
|
||||
|
||||
|
||||
@@ -365,7 +365,7 @@ class IntegrationTest(testutil.TestCase, test.TestCase):
|
||||
self.assertEqual(200, response.status_code) # Yes, it's a 200 even though it's a failure.
|
||||
payload = json.loads(response.content)
|
||||
self.assertFalse(payload.get('success'))
|
||||
self.assertIn('Before you sign in, you need to activate your account', payload.get('value'))
|
||||
self.assertIn('In order to sign in, you need to activate your account.', payload.get('value'))
|
||||
|
||||
def assert_json_failure_response_is_missing_social_auth(self, response):
|
||||
"""Asserts failure on /login for missing social auth looks right."""
|
||||
|
||||
Reference in New Issue
Block a user