From befc3f96601973583bf7f6f9c0bb8c7a5f84b91f Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Wed, 27 Nov 2019 10:18:43 -0500 Subject: [PATCH] fix: auth_cookie on localhost now being set --- ui/util/saved-passwords.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ui/util/saved-passwords.js b/ui/util/saved-passwords.js index 270fbe0b1..87df1c51d 100644 --- a/ui/util/saved-passwords.js +++ b/ui/util/saved-passwords.js @@ -1,8 +1,8 @@ // @flow -import config from 'config'; import { ipcRenderer } from 'electron'; import { DOMAIN } from 'config'; +const isProduction = process.env.NODE_ENV === 'production'; let sessionPassword; function setCookie(name: string, value: string, days: number) { @@ -10,10 +10,15 @@ function setCookie(name: string, value: string, days: number) { if (days) { let date = new Date(); date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); - expires = '; expires=' + date.toUTCString(); + expires = `expires=${date.toUTCString()};`; } - document.cookie = `${name}=${value || ''}${expires}; domain=.${DOMAIN}; path=/; SameSite=Lax; Secure;`; + let cookie = `${name}=${value || ''}; ${expires} path=/; SameSite=Lax;`; + if (isProduction) { + cookie += ` domain=.${DOMAIN}; Secure;`; + } + + document.cookie = cookie; } function getCookie(name: string) {