fix: auth_cookie on localhost now being set

This commit is contained in:
Sean Yesmunt 2019-11-27 10:18:43 -05:00
parent c72fc19fd4
commit befc3f9660

View file

@ -1,8 +1,8 @@
// @flow // @flow
import config from 'config';
import { ipcRenderer } from 'electron'; import { ipcRenderer } from 'electron';
import { DOMAIN } from 'config'; import { DOMAIN } from 'config';
const isProduction = process.env.NODE_ENV === 'production';
let sessionPassword; let sessionPassword;
function setCookie(name: string, value: string, days: number) { function setCookie(name: string, value: string, days: number) {
@ -10,10 +10,15 @@ function setCookie(name: string, value: string, days: number) {
if (days) { if (days) {
let date = new Date(); let date = new Date();
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); 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) { function getCookie(name: string) {