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
eecc0a0a
Commit
eecc0a0a
authored
Dec 20, 2017
by
asadiqbal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Applied readonly restriction on email field.
- Updated the code as per some suggestions.
parent
1fa5c38a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
35 deletions
+45
-35
lms/djangoapps/student_account/views.py
+5
-11
lms/static/js/student_account/views/AccessView.js
+1
-1
lms/templates/student_account/form_field.underscore
+1
-0
lms/templates/student_account/login.underscore
+1
-1
openedx/core/djangoapps/user_api/api.py
+36
-21
openedx/core/djangoapps/user_api/helpers.py
+1
-1
No files found.
lms/djangoapps/student_account/views.py
View file @
eecc0a0a
...
...
@@ -123,14 +123,6 @@ def login_and_registration_form(request, initial_mode="login"):
}
for
message
in
messages
.
get_messages
(
request
)
if
'account-activation'
in
message
.
tags
]
# add user details from running pipeline
pipeline_user_details
=
{}
running_pipeline
=
pipeline
.
get
(
request
)
if
running_pipeline
:
pipeline_user_details
=
running_pipeline
[
'kwargs'
][
'details'
]
enterprise_customer
=
enterprise_customer_for_request
(
request
)
# Otherwise, render the combined login/registration page
context
=
{
'data'
:
{
...
...
@@ -153,9 +145,7 @@ def login_and_registration_form(request, initial_mode="login"):
'registration_form_desc'
:
json
.
loads
(
form_descriptions
[
'registration'
]),
'password_reset_form_desc'
:
json
.
loads
(
form_descriptions
[
'password_reset'
]),
'account_creation_allowed'
:
configuration_helpers
.
get_value
(
'ALLOW_PUBLIC_ACCOUNT_CREATION'
,
settings
.
FEATURES
.
get
(
'ALLOW_PUBLIC_ACCOUNT_CREATION'
,
True
)),
'pipeline_user_details'
:
pipeline_user_details
,
'enterprise_name'
:
enterprise_customer
.
get
(
'name'
)
if
enterprise_customer
else
None
'ALLOW_PUBLIC_ACCOUNT_CREATION'
,
settings
.
FEATURES
.
get
(
'ALLOW_PUBLIC_ACCOUNT_CREATION'
,
True
))
},
'login_redirect_url'
:
redirect_to
,
# This gets added to the query string of the "Sign In" button in header
'responsive'
:
True
,
...
...
@@ -245,6 +235,8 @@ def update_context_for_enterprise(request, context):
context
=
context
.
copy
()
sidebar_context
=
enterprise_sidebar_context
(
request
)
enterprise_customer
=
enterprise_customer_for_request
(
request
)
context
[
'data'
][
'enterprise_name'
]
=
enterprise_customer
.
get
(
'name'
)
if
enterprise_customer
else
None
if
sidebar_context
:
context
[
'data'
][
'registration_form_desc'
][
'fields'
]
=
enterprise_fields_only
(
...
...
@@ -337,6 +329,7 @@ def _third_party_auth_context(request, redirect_to, tpa_hint=None):
"errorMessage"
:
None
,
"registerFormSubmitButtonText"
:
_
(
"Create Account"
),
"syncLearnerProfileData"
:
False
,
"pipeline_user_details"
:
None
}
if
third_party_auth
.
is_enabled
():
...
...
@@ -364,6 +357,7 @@ def _third_party_auth_context(request, redirect_to, tpa_hint=None):
running_pipeline
=
pipeline
.
get
(
request
)
if
running_pipeline
is
not
None
:
current_provider
=
third_party_auth
.
provider
.
Registry
.
get_from_pipeline
(
running_pipeline
)
context
[
'pipeline_user_details'
]
=
running_pipeline
[
'kwargs'
][
'details'
]
if
current_provider
is
not
None
:
context
[
"currentProvider"
]
=
current_provider
.
name
...
...
lms/static/js/student_account/views/AccessView.js
View file @
eecc0a0a
...
...
@@ -75,7 +75,7 @@
this
.
passwordResetSupportUrl
=
options
.
password_reset_support_link
;
this
.
createAccountOption
=
options
.
account_creation_allowed
;
this
.
hideAuthWarnings
=
options
.
hide_auth_warnings
||
false
;
this
.
pipelineUserDetails
=
options
.
pipeline_user_details
;
this
.
pipelineUserDetails
=
options
.
third_party_auth
.
pipeline_user_details
;
this
.
enterpriseName
=
options
.
enterprise_name
||
''
;
// The login view listens for 'sync' events from the reset model
...
...
lms/templates/student_account/form_field.underscore
View file @
eecc0a0a
...
...
@@ -91,6 +91,7 @@
<% } %>
<% if ( restrictions.min_length ) { %> minlength="<%- restrictions.min_length %>"<% } %>
<% if ( restrictions.max_length ) { %> maxlength="<%- restrictions.max_length %>"<% } %>
<% if ( restrictions.readonly ) { %> readonly <% } %>
<% if ( required ) { %> required<% } %>
<% if ( typeof errorMessages !== 'undefined' ) {
_.each(errorMessages, function( msg, type ) {%>
...
...
lms/templates/student_account/login.underscore
View file @
eecc0a0a
<div class="js-form-feedback" aria-live="assertive" tabindex="-1">
</div>
<% if ( context.createAccountOption !== false && context.enterpriseName == "") { %>
<% if ( context.createAccountOption !== false &&
!context.syncLearnerProfileData &&
context.enterpriseName == "") { %>
<div class="toggle-form">
<span class="text"><%- gettext("First time here?") %></span>
<a href="#login" class="form-toggle" data-type="register"><%- gettext("Create an Account.") %></a>
...
...
openedx/core/djangoapps/user_api/api.py
View file @
eecc0a0a
...
...
@@ -77,6 +77,7 @@ def get_login_session_form(request):
"""
form_desc
=
FormDescription
(
"post"
,
reverse
(
"user_api_login_session"
))
_apply_third_party_auth_overrides
(
request
,
form_desc
)
# Translators: This label appears above a field on the login form
# meant to hold the user's email address.
...
...
@@ -92,33 +93,16 @@ def get_login_session_form(request):
platform_name
=
configuration_helpers
.
get_value
(
'PLATFORM_NAME'
,
settings
.
PLATFORM_NAME
)
)
email
=
''
email_field_restrictions
=
{
"min_length"
:
accounts
.
EMAIL_MIN_LENGTH
,
"max_length"
:
accounts
.
EMAIL_MAX_LENGTH
,
}
if
third_party_auth
.
is_enabled
():
running_pipeline
=
third_party_auth
.
pipeline
.
get
(
request
)
if
running_pipeline
:
current_provider
=
third_party_auth
.
provider
.
Registry
.
get_from_pipeline
(
running_pipeline
)
if
current_provider
and
enterprise_customer_for_request
(
request
):
pipeline_kwargs
=
running_pipeline
.
get
(
'kwargs'
)
# Details about the user sent back from the provider.
details
=
pipeline_kwargs
.
get
(
'details'
)
.
copy
()
email
=
details
.
get
(
'email'
,
''
)
if
email
:
email_field_restrictions
.
update
({
"readonly"
:
True
})
form_desc
.
add_field
(
"email"
,
field_type
=
"email"
,
label
=
email_label
,
placeholder
=
email_placeholder
,
instructions
=
email_instructions
,
default
=
email
,
restrictions
=
email_field_restrictions
restrictions
=
{
"min_length"
:
accounts
.
EMAIL_MIN_LENGTH
,
"max_length"
:
accounts
.
EMAIL_MAX_LENGTH
,
}
)
# Translators: This label appears above a field on the login form
...
...
@@ -144,6 +128,37 @@ def get_login_session_form(request):
return
form_desc
def
_apply_third_party_auth_overrides
(
request
,
form_desc
):
"""Modify the login form if the user has authenticated with a third-party provider.
If a user has successfully authenticated with a third-party provider,
and an email is associated with it then we fill in the email field with readonly property.
Arguments:
request (HttpRequest): The request for the registration form, used
to determine if the user has successfully authenticated
with a third-party provider.
form_desc (FormDescription): The registration form description
"""
if
third_party_auth
.
is_enabled
():
running_pipeline
=
third_party_auth
.
pipeline
.
get
(
request
)
if
running_pipeline
:
current_provider
=
third_party_auth
.
provider
.
Registry
.
get_from_pipeline
(
running_pipeline
)
if
current_provider
and
enterprise_customer_for_request
(
request
):
pipeline_kwargs
=
running_pipeline
.
get
(
'kwargs'
)
# Details about the user sent back from the provider.
details
=
pipeline_kwargs
.
get
(
'details'
)
.
copy
()
email
=
details
.
get
(
'email'
,
''
)
# override the email field.
form_desc
.
override_field_properties
(
"email"
,
default
=
email
if
email
else
''
,
restrictions
=
{
"readonly"
:
"readonly"
}
if
email
else
{
"min_length"
:
accounts
.
EMAIL_MIN_LENGTH
,
"max_length"
:
accounts
.
EMAIL_MAX_LENGTH
,
}
)
class
RegistrationFormFactory
(
object
):
"""HTTP end-points for creating a new user. """
...
...
openedx/core/djangoapps/user_api/helpers.py
View file @
eecc0a0a
...
...
@@ -126,7 +126,7 @@ class FormDescription(object):
ALLOWED_RESTRICTIONS
=
{
"text"
:
[
"min_length"
,
"max_length"
],
"password"
:
[
"min_length"
,
"max_length"
],
"email"
:
[
"min_length"
,
"max_length"
],
"email"
:
[
"min_length"
,
"max_length"
,
"readonly"
],
}
FIELD_TYPE_MAP
=
{
...
...
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