Revert "ENT-1116: Add recovery email to account settings page"
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.16 on 2018-12-04 10:03
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('student', '0016_coursenrollment_course_on_delete_do_nothing'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='userprofile',
|
||||
name='secondary_email',
|
||||
field=models.EmailField(blank=True, max_length=254, verbose_name='Secondary email address'),
|
||||
),
|
||||
]
|
||||
@@ -410,7 +410,6 @@ class UserProfile(models.Model):
|
||||
# This is not visible to other users, but could introduce holes later
|
||||
user = models.OneToOneField(User, unique=True, db_index=True, related_name='profile', on_delete=models.CASCADE)
|
||||
name = models.CharField(blank=True, max_length=255, db_index=True)
|
||||
secondary_email = models.EmailField(verbose_name=_('Secondary email address'), blank=True)
|
||||
|
||||
meta = models.TextField(blank=True) # JSON dictionary for future expansion
|
||||
courseware = models.CharField(blank=True, max_length=255, default='course.xml')
|
||||
|
||||
@@ -125,8 +125,8 @@ def csrf_token(context):
|
||||
token = context.get('csrf_token', '')
|
||||
if token == 'NOTPROVIDED':
|
||||
return ''
|
||||
return (HTML(u'<div style="display:none"><input type="hidden"'
|
||||
' name="csrfmiddlewaretoken" value="{}" /></div>').format(token))
|
||||
return (u'<div style="display:none"><input type="hidden"'
|
||||
' name="csrfmiddlewaretoken" value="{}" /></div>'.format(token))
|
||||
|
||||
|
||||
# NOTE: This view is not linked to directly--it is called from
|
||||
@@ -912,33 +912,6 @@ def validate_new_email(user, new_email):
|
||||
raise ValueError(_('Old email is the same as the new email.'))
|
||||
|
||||
|
||||
def validate_secondary_email(user_profile, new_email):
|
||||
"""
|
||||
Enforce valid email addresses.
|
||||
"""
|
||||
from openedx.core.djangoapps.user_api.accounts.api import get_email_validation_error, \
|
||||
get_email_existence_validation_error, get_secondary_email_validation_error
|
||||
|
||||
if get_email_validation_error(new_email):
|
||||
raise ValueError(_('Valid e-mail address required.'))
|
||||
|
||||
if user_profile.secondary_email and new_email == user_profile.secondary_email:
|
||||
raise ValueError(_('Old email is the same as the new email.'))
|
||||
|
||||
# Make sure that secondary email address is not same as user's primary email.
|
||||
if new_email == user_profile.user.email:
|
||||
raise ValueError(_('Cannot be same as your sign in email address.'))
|
||||
|
||||
# Make sure that secondary email address is not same as any of the primary emails.
|
||||
message = get_email_existence_validation_error(new_email)
|
||||
if message:
|
||||
raise ValueError(message)
|
||||
|
||||
message = get_secondary_email_validation_error(new_email)
|
||||
if message:
|
||||
raise ValueError(message)
|
||||
|
||||
|
||||
def do_email_change_request(user, new_email, activation_key=None):
|
||||
"""
|
||||
Given a new email for a user, does some basic verification of the new address and sends an activation message
|
||||
|
||||
Reference in New Issue
Block a user