Commit 545f5219 by Will Daly

Merge pull request #8652 from edx/will/logged-in-cookie-cleanup

Remove duplicate logged-in-cookie helper methods
parents 9d6d922e b89ad57c
...@@ -1550,33 +1550,6 @@ def create_account_with_params(request, params): ...@@ -1550,33 +1550,6 @@ def create_account_with_params(request, params):
AUDIT_LOG.info(u"Login activated on extauth account - {0} ({1})".format(new_user.username, new_user.email)) AUDIT_LOG.info(u"Login activated on extauth account - {0} ({1})".format(new_user.username, new_user.email))
def set_marketing_cookie(request, response):
"""
Set the login cookie for the edx marketing site on the given response. Its
expiration will match that of the given request's session.
"""
if request.session.get_expire_at_browser_close():
max_age = None
expires = None
else:
max_age = request.session.get_expiry_age()
expires_time = time.time() + max_age
expires = cookie_date(expires_time)
# we want this cookie to be accessed via javascript
# so httponly is set to None
response.set_cookie(
settings.EDXMKTG_COOKIE_NAME,
'true',
max_age=max_age,
expires=expires,
domain=settings.SESSION_COOKIE_DOMAIN,
path='/',
secure=None,
httponly=None
)
@csrf_exempt @csrf_exempt
def create_account(request, post_override=None): def create_account(request, post_override=None):
""" """
...@@ -1611,7 +1584,7 @@ def create_account(request, post_override=None): ...@@ -1611,7 +1584,7 @@ def create_account(request, post_override=None):
'success': True, 'success': True,
'redirect_url': redirect_url, 'redirect_url': redirect_url,
}) })
set_marketing_cookie(request, response) set_logged_in_cookie(request, response)
return response return response
......
...@@ -24,7 +24,8 @@ from openedx.core.lib.api.permissions import ApiKeyHeaderPermission ...@@ -24,7 +24,8 @@ from openedx.core.lib.api.permissions import ApiKeyHeaderPermission
import third_party_auth import third_party_auth
from django_comment_common.models import Role from django_comment_common.models import Role
from edxmako.shortcuts import marketing_link from edxmako.shortcuts import marketing_link
from student.views import create_account_with_params, set_marketing_cookie from student.views import create_account_with_params
from student.helpers import set_logged_in_cookie
from openedx.core.lib.api.authentication import SessionAuthenticationAllowInactiveUser from openedx.core.lib.api.authentication import SessionAuthenticationAllowInactiveUser
from util.json_request import JsonResponse from util.json_request import JsonResponse
from .preferences.api import update_email_opt_in from .preferences.api import update_email_opt_in
...@@ -306,7 +307,7 @@ class RegistrationView(APIView): ...@@ -306,7 +307,7 @@ class RegistrationView(APIView):
return JsonResponse(errors, status=400) return JsonResponse(errors, status=400)
response = JsonResponse({"success": True}) response = JsonResponse({"success": True})
set_marketing_cookie(request, response) set_logged_in_cookie(request, response)
return response return response
def _add_email_field(self, form_desc, required=True): def _add_email_field(self, form_desc, required=True):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment