Revert "ENT-1116: Add recovery email to account settings page"
This commit is contained in:
@@ -151,10 +151,6 @@ def update_account_settings(requesting_user, update, username=None):
|
||||
changing_full_name = True
|
||||
old_name = existing_user_profile.name
|
||||
|
||||
changing_secondary_email = False
|
||||
if "secondary_email" in update:
|
||||
changing_secondary_email = True
|
||||
|
||||
# Check for fields that are not editable. Marking them read-only causes them to be ignored, but we wish to 400.
|
||||
read_only_fields = set(update.keys()).intersection(
|
||||
AccountUserSerializer.get_read_only_fields() + AccountLegacyProfileSerializer.get_read_only_fields()
|
||||
@@ -192,15 +188,6 @@ def update_account_settings(requesting_user, update, username=None):
|
||||
# This is so that this endpoint cannot be used to determine if an email is valid or not.
|
||||
changing_email = new_email and not email_exists_or_retired(new_email)
|
||||
|
||||
if changing_secondary_email:
|
||||
try:
|
||||
student_views.validate_secondary_email(existing_user_profile, update["secondary_email"])
|
||||
except ValueError as err:
|
||||
field_errors["secondary_email"] = {
|
||||
"developer_message": u"Error thrown from validate_secondary_email: '{}'".format(text_type(err)),
|
||||
"user_message": text_type(err)
|
||||
}
|
||||
|
||||
# If the user asked to change full name, validate it
|
||||
if changing_full_name:
|
||||
try:
|
||||
@@ -498,19 +485,6 @@ def get_email_validation_error(email):
|
||||
return _validate(_validate_email, errors.AccountEmailInvalid, email)
|
||||
|
||||
|
||||
def get_secondary_email_validation_error(email):
|
||||
"""
|
||||
Get the built-in validation error message for when the email is invalid in some way.
|
||||
|
||||
Arguments:
|
||||
email (str): The proposed email (unicode).
|
||||
Returns:
|
||||
(str): Validation error message.
|
||||
|
||||
"""
|
||||
return _validate(_validate_secondary_email_doesnt_exist, errors.AccountEmailAlreadyExists, email)
|
||||
|
||||
|
||||
def get_confirm_email_validation_error(confirm_email, email):
|
||||
"""Get the built-in validation error message for when
|
||||
the confirmation email is invalid in some way.
|
||||
@@ -735,18 +709,6 @@ def _validate_email_doesnt_exist(email):
|
||||
raise errors.AccountEmailAlreadyExists(_(accounts.EMAIL_CONFLICT_MSG).format(email_address=email))
|
||||
|
||||
|
||||
def _validate_secondary_email_doesnt_exist(email):
|
||||
"""Validate that the email is not associated as a secondary email of an existing user.
|
||||
|
||||
:param email: The proposed email (unicode).
|
||||
:return: None
|
||||
:raises: errors.AccountEmailAlreadyExists
|
||||
"""
|
||||
if email is not None and UserProfile.objects.filter(secondary_email=email).exists():
|
||||
# pylint: disable=no-member
|
||||
raise errors.AccountEmailAlreadyExists(accounts.EMAIL_CONFLICT_MSG.format(email_address=email))
|
||||
|
||||
|
||||
def _validate_password_works_with_username(password, username=None):
|
||||
"""Run validation checks on whether the password and username
|
||||
go well together.
|
||||
|
||||
@@ -14,7 +14,6 @@ from six import text_type
|
||||
from lms.djangoapps.badges.utils import badges_enabled
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
from openedx.core.djangoapps.user_api import errors
|
||||
from openedx.core.djangoapps.user_api.accounts.utils import is_secondary_email_feature_enabled_for_user
|
||||
from openedx.core.djangoapps.user_api.models import (
|
||||
RetirementState,
|
||||
UserPreference,
|
||||
@@ -148,7 +147,6 @@ class UserReadOnlySerializer(serializers.Serializer):
|
||||
user_profile.social_links.all(), many=True
|
||||
).data,
|
||||
"extended_profile": get_extended_profile(user_profile),
|
||||
"secondary_email": user_profile.secondary_email,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -159,10 +157,6 @@ class UserReadOnlySerializer(serializers.Serializer):
|
||||
else:
|
||||
fields = self.configuration.get('public_fields')
|
||||
|
||||
# Do not display secondary email input field, if secondary email feature is not enabled for the current user.
|
||||
if 'secondary_email' in fields and not is_secondary_email_feature_enabled_for_user(user):
|
||||
fields.remove('secondary_email')
|
||||
|
||||
return self._filter_fields(
|
||||
fields,
|
||||
data
|
||||
@@ -204,8 +198,7 @@ class AccountLegacyProfileSerializer(serializers.HyperlinkedModelSerializer, Rea
|
||||
model = UserProfile
|
||||
fields = (
|
||||
"name", "gender", "goals", "year_of_birth", "level_of_education", "country", "social_links",
|
||||
"mailing_address", "bio", "profile_image", "requires_parental_consent", "language_proficiencies",
|
||||
"secondary_email"
|
||||
"mailing_address", "bio", "profile_image", "requires_parental_consent", "language_proficiencies"
|
||||
)
|
||||
# Currently no read-only field, but keep this so view code doesn't need to know.
|
||||
read_only_fields = ()
|
||||
|
||||
@@ -8,7 +8,6 @@ import re
|
||||
import string
|
||||
from urlparse import urlparse
|
||||
|
||||
import waffle
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext as _
|
||||
from six import text_type
|
||||
@@ -20,8 +19,6 @@ from openedx.core.djangoapps.theming.helpers import get_config_value_from_site_o
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore.exceptions import ItemNotFoundError
|
||||
|
||||
ENABLE_SECONDARY_EMAIL_FEATURE_SWITCH = 'enable_secondary_email_feature'
|
||||
|
||||
|
||||
def validate_social_link(platform_name, new_social_link):
|
||||
"""
|
||||
@@ -192,25 +189,3 @@ def generate_password(length=12, chars=string.letters + string.digits):
|
||||
password += choice(string.letters)
|
||||
password += ''.join([choice(chars) for _i in xrange(length - 2)])
|
||||
return password
|
||||
|
||||
|
||||
def is_secondary_email_feature_enabled():
|
||||
"""
|
||||
Checks to see if the django-waffle switch for enabling the secondary email feature is active
|
||||
|
||||
Returns:
|
||||
Boolean value representing switch status
|
||||
"""
|
||||
return waffle.switch_is_active(ENABLE_SECONDARY_EMAIL_FEATURE_SWITCH)
|
||||
|
||||
|
||||
def is_secondary_email_feature_enabled_for_user(user):
|
||||
"""
|
||||
Checks to see if secondary email feature is enabled for the given user.
|
||||
|
||||
Returns:
|
||||
Boolean value representing the status of secondary email feature.
|
||||
"""
|
||||
# import is placed here to avoid cyclic import.
|
||||
from openedx.features.enterprise_support.utils import is_enterprise_learner
|
||||
return is_secondary_email_feature_enabled() and is_enterprise_learner(user)
|
||||
|
||||
@@ -666,7 +666,7 @@ class TestMessageDeduplication(ModuleStoreTestCase):
|
||||
|
||||
self.user = UserFactory.create()
|
||||
self.request_factory = RequestFactory()
|
||||
ContentTypeGatingConfig.objects.create(enabled=True, enabled_as_of=datetime(2018, 1, 1))
|
||||
ContentTypeGatingConfig.objects.create(enabled=True, enabled_as_of=date(2018, 1, 1))
|
||||
|
||||
def _create_course(self):
|
||||
course = CourseFactory.create(run='test', display_name='test')
|
||||
|
||||
@@ -9,7 +9,6 @@ from django.utils.translation import ugettext as _
|
||||
|
||||
import third_party_auth
|
||||
from third_party_auth import pipeline
|
||||
from enterprise.models import EnterpriseCustomerUser
|
||||
|
||||
from openedx.core.djangoapps.user_authn.cookies import standard_cookie_settings
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
@@ -258,16 +257,3 @@ def get_enterprise_learner_generic_name(request):
|
||||
if enterprise_customer and enterprise_customer['replace_sensitive_sso_username']
|
||||
else ''
|
||||
)
|
||||
|
||||
|
||||
def is_enterprise_learner(user):
|
||||
"""
|
||||
Check if the given user belongs to an enterprise.
|
||||
|
||||
Arguments:
|
||||
user (User): Django User object.
|
||||
|
||||
Returns:
|
||||
(bool): True if given user is an enterprise learner.
|
||||
"""
|
||||
return EnterpriseCustomerUser.objects.filter(user_id=user.id).exists()
|
||||
|
||||
Reference in New Issue
Block a user