File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
common/djangoapps/student
openedx/core/djangoapps/user_authn/views Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 19
19
from django .core .exceptions import PermissionDenied
20
20
from django .core .validators import ValidationError
21
21
from django .db import IntegrityError , transaction
22
+ from django .shortcuts import redirect
22
23
from django .urls import NoReverseMatch , reverse
23
24
from django .utils .translation import ugettext as _
24
25
from pytz import UTC
@@ -739,3 +740,16 @@ def sanitize_next_parameter(next_param):
739
740
return sanitized_next_parameter
740
741
741
742
return next_param
743
+
744
+
745
+ def add_hide_elements_cookie_to_redirect (redirect_to ):
746
+ if 'hide_elements' in redirect_to :
747
+ # Perform the redirect and set the cookie only if 'hide_elements' is present
748
+ response = redirect (redirect_to )
749
+
750
+ # Set a cookie to indicate that elements should be hidden
751
+ response .set_cookie ('hideElements' , 'true' , max_age = 86400 )
752
+
753
+ return response
754
+ else :
755
+ return redirect (redirect_to )
Original file line number Diff line number Diff line change 30
30
handle_enterprise_cookies_for_logistration ,
31
31
update_logistration_context_for_enterprise
32
32
)
33
- from student .helpers import get_next_url_for_login_page
33
+ from student .helpers import get_next_url_for_login_page , add_hide_elements_cookie_to_redirect
34
34
from third_party_auth import pipeline
35
35
from third_party_auth .decorators import xframe_allow_whitelisted
36
36
from util .password_policy_validators import DEFAULT_MAX_PASSWORD_LENGTH
@@ -146,12 +146,14 @@ def login_and_registration_form(request, initial_mode="login"):
146
146
# since Django's SessionAuthentication middleware auto-updates session cookies but not
147
147
# the other login-related cookies. See ARCH-282.
148
148
if request .user .is_authenticated and are_logged_in_cookies_set (request ):
149
- return redirect (redirect_to )
149
+ response = add_hide_elements_cookie_to_redirect (redirect_to )
150
+ return response
150
151
151
152
# Tahoe: Disable upstream login/register forms when the Tahoe Identity Provider is enabled.
152
153
tahoe_idp_redirect_url = tahoe_idp_helpers .get_idp_form_url (request , initial_mode , redirect_to )
153
154
if tahoe_idp_redirect_url :
154
- return redirect (tahoe_idp_redirect_url )
155
+ response = add_hide_elements_cookie_to_redirect (tahoe_idp_redirect_url )
156
+ return response
155
157
156
158
# Retrieve the form descriptions from the user API
157
159
form_descriptions = _get_form_descriptions (request )
You can’t perform that action at this time.
0 commit comments