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
ef1bc239
Commit
ef1bc239
authored
Jan 30, 2012
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JSON password reset
parent
cf1b0a86
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
auth/views.py
+16
-2
urls.py
+1
-0
No files found.
auth/views.py
View file @
ef1bc239
...
...
@@ -5,12 +5,12 @@ import string
from
django.conf
import
settings
from
django.contrib.auth
import
logout
,
authenticate
,
login
from
django.contrib.auth.
models
import
User
from
django.contrib.auth.
forms
import
PasswordResetForm
from
django.contrib.auth.models
import
User
from
django.core.context_processors
import
csrf
from
django.core.validators
import
validate_email
,
validate_slug
from
django.db
import
connection
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
,
Http404
from
django.shortcuts
import
redirect
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
models
import
Registration
,
UserProfile
...
...
@@ -230,3 +230,17 @@ def activate_account(request, key):
if
len
(
r
)
==
0
:
return
render_to_response
(
"activation_invalid.html"
,{
'csrf'
:
csrf
(
request
)[
'csrf_token'
]})
return
HttpResponse
(
"Unknown error. Please e-mail us to let us know how it happened."
)
def
password_reset
(
request
):
''' Attempts to send a password reset e-mail. '''
if
request
.
method
!=
"POST"
:
raise
Http404
form
=
PasswordResetForm
(
request
.
POST
)
if
form
.
is_valid
():
form
.
save
(
use_https
=
request
.
is_secure
(),
from_email
=
settings
.
DEFAULT_FROM_EMAIL
,
request
=
request
)
return
HttpResponse
(
json
.
dumps
({
'success'
:
True
}))
else
:
return
HttpResponse
(
json
.
dumps
({
'success'
:
False
,
'error'
:
'Invalid e-mail'
}))
urls.py
View file @
ef1bc239
...
...
@@ -19,6 +19,7 @@ urlpatterns = ('',
url
(
r'^$'
,
'auth.views.index'
),
url
(
r'^password_reset/$'
,
'django.contrib.auth.views.password_reset'
,
dict
(
from_email
=
'registration@mitx.mit.edu'
),
name
=
'auth_password_reset'
),
# url(r'^password_reset/$', 'auth.views.password_reset'),
url
(
r'^password_change/$'
,
django
.
contrib
.
auth
.
views
.
password_change
,
name
=
'auth_password_change'
),
url
(
r'^password_change_done/$'
,
django
.
contrib
.
auth
.
views
.
password_change_done
,
name
=
'auth_password_change_done'
),
url
(
r'^password_reset_confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$'
,
django
.
contrib
.
auth
.
views
.
password_reset_confirm
,
...
...
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