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
0cb798b4
Commit
0cb798b4
authored
Mar 28, 2012
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proper e-mail address validation
parent
85cc9c4a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
djangoapps/student/views.py
+9
-3
No files found.
djangoapps/student/views.py
View file @
0cb798b4
...
...
@@ -11,7 +11,7 @@ from django.contrib.auth.forms import PasswordResetForm
from
django.contrib.auth.models
import
User
from
django.core.context_processors
import
csrf
from
django.core.mail
import
send_mail
from
django.core.validators
import
validate_email
,
validate_slug
from
django.core.validators
import
validate_email
,
validate_slug
,
ValidationError
from
django.db
import
connection
from
django.http
import
HttpResponse
,
Http404
from
django.shortcuts
import
redirect
...
...
@@ -148,13 +148,13 @@ def create_account(request, post_override=None):
try
:
validate_email
(
post_vars
[
'email'
])
except
:
except
ValidationError
:
js
[
'value'
]
=
"Valid e-mail is required."
.
format
(
field
=
a
)
return
HttpResponse
(
json
.
dumps
(
js
))
try
:
validate_slug
(
post_vars
[
'username'
])
except
:
except
ValidationError
:
js
[
'value'
]
=
"Username should only consist of A-Z and 0-9."
.
format
(
field
=
a
)
return
HttpResponse
(
json
.
dumps
(
js
))
...
...
@@ -307,6 +307,12 @@ def change_email_request(request):
'error'
:
'Invalid password'
}))
new_email
=
request
.
POST
[
'new_email'
]
try
:
validate_email
(
new_email
)
except
ValidationError
:
return
HttpResponse
(
json
.
dumps
({
'success'
:
False
,
'error'
:
'Valid e-mail address required.'
}))
if
len
(
User
.
objects
.
filter
(
email
=
new_email
))
!=
0
:
## CRITICAL TODO: Handle case sensitivity for e-mails
return
HttpResponse
(
json
.
dumps
({
'success'
:
False
,
...
...
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