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
4fd43029
Unverified
Commit
4fd43029
authored
Nov 10, 2017
by
adeel khan
Committed by
GitHub
Nov 10, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16518 from edx/adeel/LEARNER_2571_studentaccountview_error_handle
Adds error handling for password reset
parents
4c643438
3f61f50d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletions
+15
-1
lms/djangoapps/student_account/test/test_views.py
+7
-0
lms/djangoapps/student_account/views.py
+8
-1
No files found.
lms/djangoapps/student_account/test/test_views.py
View file @
4fd43029
...
...
@@ -44,6 +44,7 @@ from student_account.views import account_settings_context, get_user_orders
from
third_party_auth.tests.testutil
import
ThirdPartyAuthTestMixin
,
simulate_running_pipeline
from
util.testing
import
UrlResetMixin
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
openedx.core.djangoapps.user_api.errors
import
UserAPIInternalError
LOGGER_NAME
=
'audit'
User
=
get_user_model
()
# pylint:disable=invalid-name
...
...
@@ -131,6 +132,12 @@ class StudentAccountUpdateTest(CacheIsolationTestCase, UrlResetMixin):
result
=
self
.
client
.
login
(
username
=
self
.
USERNAME
,
password
=
self
.
NEW_PASSWORD
)
self
.
assertTrue
(
result
)
def
test_password_change_failure
(
self
):
with
mock
.
patch
(
'openedx.core.djangoapps.user_api.accounts.api.request_password_change'
,
side_effect
=
UserAPIInternalError
):
self
.
_change_password
()
self
.
assertRaises
(
UserAPIInternalError
)
@ddt.data
(
True
,
False
)
def
test_password_change_logged_out
(
self
,
send_email
):
# Log the user out
...
...
lms/djangoapps/student_account/views.py
View file @
4fd43029
...
...
@@ -34,7 +34,10 @@ from openedx.core.djangoapps.user_api.api import (
get_login_session_form
,
get_password_reset_form
)
from
openedx.core.djangoapps.user_api.errors
import
UserNotFound
from
openedx.core.djangoapps.user_api.errors
import
(
UserNotFound
,
UserAPIInternalError
)
from
openedx.core.lib.edx_api_utils
import
get_edx_api_data
from
openedx.core.lib.time_zone_utils
import
TIME_ZONE_CHOICES
from
openedx.features.enterprise_support.api
import
enterprise_customer_for_request
...
...
@@ -213,6 +216,10 @@ def password_change_request_handler(request):
AUDIT_LOG
.
info
(
"Invalid password reset attempt"
)
# Increment the rate limit counter
limiter
.
tick_bad_request_counter
(
request
)
except
UserAPIInternalError
as
err
:
log
.
exception
(
'Error occured during password change for user {email}: {error}'
.
format
(
email
=
email
,
error
=
err
))
return
HttpResponse
(
_
(
"Some error occured during password change. Please try again"
),
status
=
500
)
return
HttpResponse
(
status
=
200
)
else
:
...
...
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