Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
25ca62d9
Commit
25ca62d9
authored
13 years ago
by
Piotr Mitros
Browse files
Options
Downloads
Patches
Plain Diff
Proper e-mail address validation
parent
f6787bd8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
djangoapps/student/views.py
+9
-3
9 additions, 3 deletions
djangoapps/student/views.py
with
9 additions
and
3 deletions
djangoapps/student/views.py
+
9
−
3
View file @
25ca62d9
...
@@ -11,7 +11,7 @@ from django.contrib.auth.forms import PasswordResetForm
...
@@ -11,7 +11,7 @@ from django.contrib.auth.forms import PasswordResetForm
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.core.context_processors
import
csrf
from
django.core.context_processors
import
csrf
from
django.core.mail
import
send_mail
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.db
import
connection
from
django.http
import
HttpResponse
,
Http404
from
django.http
import
HttpResponse
,
Http404
from
django.shortcuts
import
redirect
from
django.shortcuts
import
redirect
...
@@ -148,13 +148,13 @@ def create_account(request, post_override=None):
...
@@ -148,13 +148,13 @@ def create_account(request, post_override=None):
try
:
try
:
validate_email
(
post_vars
[
'
email
'
])
validate_email
(
post_vars
[
'
email
'
])
except
:
except
ValidationError
:
js
[
'
value
'
]
=
"
Valid e-mail is required.
"
.
format
(
field
=
a
)
js
[
'
value
'
]
=
"
Valid e-mail is required.
"
.
format
(
field
=
a
)
return
HttpResponse
(
json
.
dumps
(
js
))
return
HttpResponse
(
json
.
dumps
(
js
))
try
:
try
:
validate_slug
(
post_vars
[
'
username
'
])
validate_slug
(
post_vars
[
'
username
'
])
except
:
except
ValidationError
:
js
[
'
value
'
]
=
"
Username should only consist of A-Z and 0-9.
"
.
format
(
field
=
a
)
js
[
'
value
'
]
=
"
Username should only consist of A-Z and 0-9.
"
.
format
(
field
=
a
)
return
HttpResponse
(
json
.
dumps
(
js
))
return
HttpResponse
(
json
.
dumps
(
js
))
...
@@ -307,6 +307,12 @@ def change_email_request(request):
...
@@ -307,6 +307,12 @@ def change_email_request(request):
'
error
'
:
'
Invalid password
'
}))
'
error
'
:
'
Invalid password
'
}))
new_email
=
request
.
POST
[
'
new_email
'
]
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
:
if
len
(
User
.
objects
.
filter
(
email
=
new_email
))
!=
0
:
## CRITICAL TODO: Handle case sensitivity for e-mails
## CRITICAL TODO: Handle case sensitivity for e-mails
return
HttpResponse
(
json
.
dumps
({
'
success
'
:
False
,
return
HttpResponse
(
json
.
dumps
({
'
success
'
:
False
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment