Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
3bd45358
Commit
3bd45358
authored
Apr 28, 2015
by
Awais Jibran
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7753 from edx/aj/tnl1745-change-email-on-dashboard
Fixed change email address error from student dashboard
parents
70d837ab
1d9499e1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletions
+31
-1
common/djangoapps/student/tests/test_email.py
+26
-0
common/djangoapps/student/views.py
+5
-1
No files found.
common/djangoapps/student/tests/test_email.py
View file @
3bd45358
...
...
@@ -243,6 +243,32 @@ class EmailChangeRequestTests(EventTestMixin, TestCase):
self
.
request
.
POST
[
'password'
]
=
'wrong'
self
.
assertFailedRequest
(
self
.
run_request
(),
'Invalid password'
)
@patch
(
'student.views.render_to_string'
,
Mock
(
side_effect
=
mock_render_to_string
,
autospec
=
True
))
def
test_duplicate_activation_key
(
self
):
"""Assert that if two users change Email address simultaneously, server should return 200"""
# New emails for the users
user1_new_email
=
"valid_user1_email@example.com"
user2_new_email
=
"valid_user2_email@example.com"
# Set new email for user1.
self
.
request
.
POST
[
'new_email'
]
=
user1_new_email
# Create a another user 'user2' & make request for change email
user2
=
UserFactory
.
create
(
email
=
self
.
new_email
,
password
=
"test2"
)
user2_request
=
self
.
req_factory
.
post
(
'unused_url'
,
data
=
{
'password'
:
'test2'
,
'new_email'
:
user2_new_email
})
user2_request
.
user
=
user2
# Send requests & check if response was successful
user1_response
=
change_email_request
(
self
.
request
)
user2_response
=
change_email_request
(
user2_request
)
self
.
assertEqual
(
user1_response
.
status_code
,
200
)
self
.
assertEqual
(
user2_response
.
status_code
,
200
)
def
test_invalid_emails
(
self
):
for
email
in
(
'bad_email'
,
'bad_email@'
,
'@bad_email'
):
self
.
request
.
POST
[
'new_email'
]
=
email
...
...
common/djangoapps/student/views.py
View file @
3bd45358
...
...
@@ -2025,7 +2025,7 @@ def validate_new_email(user, new_email):
raise
ValueError
(
_
(
'An account with this e-mail already exists.'
))
def
do_email_change_request
(
user
,
new_email
,
activation_key
=
uuid
.
uuid4
()
.
hex
):
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
to the new address. If any issues are encountered with verification or sending the message, a ValueError will
...
...
@@ -2038,6 +2038,10 @@ def do_email_change_request(user, new_email, activation_key=uuid.uuid4().hex):
else
:
pec
=
pec_list
[
0
]
# if activation_key is not passing as an argument, generate a random key
if
not
activation_key
:
activation_key
=
uuid
.
uuid4
()
.
hex
pec
.
new_email
=
new_email
pec
.
activation_key
=
activation_key
pec
.
save
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment