From 37c5344066fc13bc021f9e92c0fce84bee1bd203 Mon Sep 17 00:00:00 2001 From: Waheed Ahmed Date: Tue, 4 May 2021 14:33:03 +0500 Subject: [PATCH] Set cookie domain. (#267) VAN-291 --- .env | 1 + .env.development | 1 + src/index.jsx | 1 + src/register/RegistrationPage.jsx | 3 ++- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 12a74c41..fdebe809 100644 --- a/.env +++ b/.env @@ -18,3 +18,4 @@ AUTHN_MINIMAL_HEADER=true LOGIN_ISSUE_SUPPORT_LINK=null REGISTRATION_OPTIONAL_FIELDS=null USER_SIGNUP_SURVEY_COOKIE_NAME=null +COOKIE_DOMAIN=null diff --git a/.env.development b/.env.development index fbf440db..5c08f92e 100644 --- a/.env.development +++ b/.env.development @@ -25,3 +25,4 @@ TOS_AND_HONOR_CODE='http://localhost:18000/honor' PRIVACY_POLICY='http://localhost:18000/privacy' REGISTRATION_OPTIONAL_FIELDS='gender,goals,level_of_education,year_of_birth' USER_SIGNUP_SURVEY_COOKIE_NAME='openedx-user-signup-timestamp' +COOKIE_DOMAIN='localhost' diff --git a/src/index.jsx b/src/index.jsx index 53683650..1d43bbdb 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -66,6 +66,7 @@ initialize({ PRIVACY_POLICY: process.env.PRIVACY_POLICY || null, REGISTRATION_OPTIONAL_FIELDS: process.env.REGISTRATION_OPTIONAL_FIELDS || '', USER_SIGNUP_SURVEY_COOKIE_NAME: process.env.USER_SIGNUP_SURVEY_COOKIE_NAME || null, + COOKIE_DOMAIN: process.env.COOKIE_DOMAIN, }); }, }, diff --git a/src/register/RegistrationPage.jsx b/src/register/RegistrationPage.jsx index e4fd36db..510f1e50 100644 --- a/src/register/RegistrationPage.jsx +++ b/src/register/RegistrationPage.jsx @@ -436,7 +436,8 @@ class RegistrationPage extends React.Component { const signupTimestamp = (new Date()).getTime(); // set expiry to exactly 24 hours from now const cookieExpiry = new Date(signupTimestamp + 1 * 864e5); - cookies.set(cookieName, signupTimestamp, { expires: cookieExpiry }); + const options = { domain: getConfig().COOKIE_DOMAIN, expires: cookieExpiry, path: '/' }; + cookies.set(cookieName, signupTimestamp, options); } }