@@ -21,7 +21,7 @@ import { child, ref, set } from 'firebase/database';
2121import { init , stores } from './stores' ;
2222import { triggerDiscordAuthFlow } from './util/auth' ;
2323import chromeStorageSyncStore from './util/chromeStorageSyncStore' ;
24- import { getHaloUserInfo } from './util/halo' ;
24+ import { AUTHORIZATION_KEY , CONTEXT_KEY , getHaloUserInfo } from './util/halo' ;
2525import { auth , db , getHaloCookies } from './util/util' ;
2626// no stores - code is not shared between background and popup
2727
@@ -85,7 +85,7 @@ const firebaseSignIn = async function () {
8585 //halo_cookies.set(await getHaloCookies()); //should be unnecessary w initial_value
8686
8787 chrome . runtime . onInstalled . addListener ( ( { reason } ) => {
88- console . log ( 'onInstalled' , reason )
88+ console . log ( 'onInstalled' , reason ) ;
8989 switch ( reason ) {
9090 case chrome . runtime . OnInstalledReason . INSTALL :
9191 // currently broken, see https://github.com/GoogleChrome/developer.chrome.com/issues/2602
@@ -150,7 +150,14 @@ const firebaseSignIn = async function () {
150150
151151 //retrieve new cookies and merge w old ones
152152 const cookies = await getHaloCookies ( ) ;
153- if ( ! cookies || ! Object . keys ( cookies ) . length ) return ; //don't push empty cookies
153+ if (
154+ ! cookies ||
155+ ! Object . keys ( cookies ) . length ||
156+ ! cookies . hasOwnProperty ( AUTHORIZATION_KEY ) ||
157+ ! cookies . hasOwnProperty ( CONTEXT_KEY )
158+ )
159+ //don't push empty cookies or cookies without both cookies
160+ return ;
154161 stores . halo_cookies . update ( cookies ) ;
155162 //push to db
156163 await set ( ref ( db , `cookies/${ auth . currentUser . uid } ` ) , cookies ) ;
0 commit comments