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
09c76a7b
Commit
09c76a7b
authored
Aug 08, 2017
by
edx-pipeline-bot
Committed by
GitHub
Aug 08, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15773 from edx/private_to_public_d28b140
Mergeback PR from private to public.
parents
98dd14f2
0ad7084d
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
26 deletions
+12
-26
common/djangoapps/student/forms.py
+0
-4
common/djangoapps/student/tests/test_reset_password.py
+6
-13
common/djangoapps/student/views.py
+1
-2
lms/djangoapps/student_account/views.py
+1
-1
openedx/core/djangoapps/user_api/accounts/api.py
+1
-2
openedx/core/djangoapps/user_api/accounts/tests/test_api.py
+3
-4
No files found.
common/djangoapps/student/forms.py
View file @
09c76a7b
...
@@ -49,7 +49,6 @@ class PasswordResetFormNoActive(PasswordResetForm):
...
@@ -49,7 +49,6 @@ class PasswordResetFormNoActive(PasswordResetForm):
def
save
(
def
save
(
self
,
self
,
domain_override
=
None
,
subject_template_name
=
'emails/password_reset_subject.txt'
,
subject_template_name
=
'emails/password_reset_subject.txt'
,
email_template_name
=
'registration/password_reset_email.html'
,
email_template_name
=
'registration/password_reset_email.html'
,
use_https
=
False
,
use_https
=
False
,
...
@@ -65,13 +64,10 @@ class PasswordResetFormNoActive(PasswordResetForm):
...
@@ -65,13 +64,10 @@ class PasswordResetFormNoActive(PasswordResetForm):
# django.contrib.auth.forms.PasswordResetForm directly, which has this import in this place.
# django.contrib.auth.forms.PasswordResetForm directly, which has this import in this place.
from
django.core.mail
import
send_mail
from
django.core.mail
import
send_mail
for
user
in
self
.
users_cache
:
for
user
in
self
.
users_cache
:
if
not
domain_override
:
site_name
=
configuration_helpers
.
get_value
(
site_name
=
configuration_helpers
.
get_value
(
'SITE_NAME'
,
'SITE_NAME'
,
settings
.
SITE_NAME
settings
.
SITE_NAME
)
)
else
:
site_name
=
domain_override
context
=
{
context
=
{
'email'
:
user
.
email
,
'email'
:
user
.
email
,
'site_name'
:
site_name
,
'site_name'
:
site_name
,
...
...
common/djangoapps/student/tests/test_reset_password.py
View file @
09c76a7b
...
@@ -175,33 +175,26 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
...
@@ -175,33 +175,26 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
"Test only valid in LMS"
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
"Test only valid in LMS"
)
@patch
(
'django.core.mail.send_mail'
)
@patch
(
'django.core.mail.send_mail'
)
@ddt.data
((
'Crazy Awesome Site'
,
'Crazy Awesome Site'
),
(
None
,
'edX'
))
@ddt.data
((
'Crazy Awesome Site'
,
'Crazy Awesome Site'
),
(
'edX'
,
'edX'
))
@ddt.unpack
@ddt.unpack
def
test_reset_password_email_
domain
(
self
,
domain_overrid
e
,
platform_name
,
send_email
):
def
test_reset_password_email_
site
(
self
,
site_nam
e
,
platform_name
,
send_email
):
"""
"""
Tests that the right url domain and platform name is included in
Tests that the right url domain and platform name is included in
the reset password email
the reset password email
"""
"""
with
patch
(
"django.conf.settings.PLATFORM_NAME"
,
platform_name
):
with
patch
(
"django.conf.settings.PLATFORM_NAME"
,
platform_name
):
with
patch
(
"django.conf.settings.SITE_NAME"
,
site_name
):
req
=
self
.
request_factory
.
post
(
req
=
self
.
request_factory
.
post
(
'/password_reset/'
,
{
'email'
:
self
.
user
.
email
}
'/password_reset/'
,
{
'email'
:
self
.
user
.
email
}
)
)
req
.
is_secure
=
Mock
(
return_value
=
True
)
req
.
get_host
=
Mock
(
return_value
=
domain_override
)
req
.
user
=
self
.
user
req
.
user
=
self
.
user
password_reset
(
req
)
password_reset
(
req
)
_
,
msg
,
_
,
_
=
send_email
.
call_args
[
0
]
_
,
msg
,
_
,
_
=
send_email
.
call_args
[
0
]
reset_intro_msg
=
"you requested a password reset for your user account at {}"
.
format
(
platform_name
)
reset_msg
=
"you requested a password reset for your user account at {}"
self
.
assertIn
(
reset_intro_msg
,
msg
)
reset_msg
=
reset_msg
.
format
(
site_name
)
reset_link
=
"https://{}/"
self
.
assertIn
(
reset_msg
,
msg
)
if
domain_override
:
reset_link
=
reset_link
.
format
(
domain_override
)
else
:
reset_link
=
reset_link
.
format
(
settings
.
SITE_NAME
)
self
.
assertIn
(
reset_link
,
msg
)
sign_off
=
"The {} Team"
.
format
(
platform_name
)
sign_off
=
"The {} Team"
.
format
(
platform_name
)
self
.
assertIn
(
sign_off
,
msg
)
self
.
assertIn
(
sign_off
,
msg
)
...
...
common/djangoapps/student/views.py
View file @
09c76a7b
...
@@ -2436,8 +2436,7 @@ def password_reset(request):
...
@@ -2436,8 +2436,7 @@ def password_reset(request):
if
form
.
is_valid
():
if
form
.
is_valid
():
form
.
save
(
use_https
=
request
.
is_secure
(),
form
.
save
(
use_https
=
request
.
is_secure
(),
from_email
=
configuration_helpers
.
get_value
(
'email_from_address'
,
settings
.
DEFAULT_FROM_EMAIL
),
from_email
=
configuration_helpers
.
get_value
(
'email_from_address'
,
settings
.
DEFAULT_FROM_EMAIL
),
request
=
request
,
request
=
request
)
domain_override
=
request
.
get_host
())
# When password change is complete, a "edx.user.settings.changed" event will be emitted.
# When password change is complete, a "edx.user.settings.changed" event will be emitted.
# But because changing the password is multi-step, we also emit an event here so that we can
# But because changing the password is multi-step, we also emit an event here so that we can
# track where the request was initiated.
# track where the request was initiated.
...
...
lms/djangoapps/student_account/views.py
View file @
09c76a7b
...
@@ -198,7 +198,7 @@ def password_change_request_handler(request):
...
@@ -198,7 +198,7 @@ def password_change_request_handler(request):
if
email
:
if
email
:
try
:
try
:
request_password_change
(
email
,
request
.
get_host
(),
request
.
is_secure
())
request_password_change
(
email
,
request
.
is_secure
())
user
=
user
if
user
.
is_authenticated
()
else
User
.
objects
.
get
(
email
=
email
)
user
=
user
if
user
.
is_authenticated
()
else
User
.
objects
.
get
(
email
=
email
)
destroy_oauth_tokens
(
user
)
destroy_oauth_tokens
(
user
)
except
UserNotFound
:
except
UserNotFound
:
...
...
openedx/core/djangoapps/user_api/accounts/api.py
View file @
09c76a7b
...
@@ -366,7 +366,7 @@ def activate_account(activation_key):
...
@@ -366,7 +366,7 @@ def activate_account(activation_key):
@helpers.intercept_errors
(
errors
.
UserAPIInternalError
,
ignore_errors
=
[
errors
.
UserAPIRequestError
])
@helpers.intercept_errors
(
errors
.
UserAPIInternalError
,
ignore_errors
=
[
errors
.
UserAPIRequestError
])
def
request_password_change
(
email
,
orig_host
,
is_secure
):
def
request_password_change
(
email
,
is_secure
):
"""Email a single-use link for performing a password reset.
"""Email a single-use link for performing a password reset.
Users must confirm the password change before we update their information.
Users must confirm the password change before we update their information.
...
@@ -395,7 +395,6 @@ def request_password_change(email, orig_host, is_secure):
...
@@ -395,7 +395,6 @@ def request_password_change(email, orig_host, is_secure):
# and email it to the user.
# and email it to the user.
form
.
save
(
form
.
save
(
from_email
=
configuration_helpers
.
get_value
(
'email_from_address'
,
settings
.
DEFAULT_FROM_EMAIL
),
from_email
=
configuration_helpers
.
get_value
(
'email_from_address'
,
settings
.
DEFAULT_FROM_EMAIL
),
domain_override
=
orig_host
,
use_https
=
is_secure
use_https
=
is_secure
)
)
else
:
else
:
...
...
openedx/core/djangoapps/user_api/accounts/tests/test_api.py
View file @
09c76a7b
...
@@ -320,7 +320,6 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
...
@@ -320,7 +320,6 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
PASSWORD
=
u'ṕáśśẃőŕd'
PASSWORD
=
u'ṕáśśẃőŕd'
EMAIL
=
u'frank+underwood@example.com'
EMAIL
=
u'frank+underwood@example.com'
ORIG_HOST
=
'example.com'
IS_SECURE
=
False
IS_SECURE
=
False
@skip_unless_lms
@skip_unless_lms
...
@@ -390,7 +389,7 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
...
@@ -390,7 +389,7 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
activate_account
(
activation_key
)
activate_account
(
activation_key
)
# Request a password change
# Request a password change
request_password_change
(
self
.
EMAIL
,
self
.
ORIG_HOST
,
self
.
IS_SECURE
)
request_password_change
(
self
.
EMAIL
,
self
.
IS_SECURE
)
# Verify that one email message has been sent
# Verify that one email message has been sent
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
...
@@ -404,7 +403,7 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
...
@@ -404,7 +403,7 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
@skip_unless_lms
@skip_unless_lms
def
test_request_password_change_invalid_user
(
self
):
def
test_request_password_change_invalid_user
(
self
):
with
self
.
assertRaises
(
UserNotFound
):
with
self
.
assertRaises
(
UserNotFound
):
request_password_change
(
self
.
EMAIL
,
self
.
ORIG_HOST
,
self
.
IS_SECURE
)
request_password_change
(
self
.
EMAIL
,
self
.
IS_SECURE
)
# Verify that no email messages have been sent
# Verify that no email messages have been sent
self
.
assertEqual
(
len
(
mail
.
outbox
),
0
)
self
.
assertEqual
(
len
(
mail
.
outbox
),
0
)
...
@@ -414,7 +413,7 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
...
@@ -414,7 +413,7 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
# Create an account, but do not activate it
# Create an account, but do not activate it
create_account
(
self
.
USERNAME
,
self
.
PASSWORD
,
self
.
EMAIL
)
create_account
(
self
.
USERNAME
,
self
.
PASSWORD
,
self
.
EMAIL
)
request_password_change
(
self
.
EMAIL
,
self
.
ORIG_HOST
,
self
.
IS_SECURE
)
request_password_change
(
self
.
EMAIL
,
self
.
IS_SECURE
)
# Verify that the activation email was still sent
# Verify that the activation email was still sent
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
...
...
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