diff --git a/src/app/style.css b/src/app/style.css index 962aafc..5fda7bb 100644 --- a/src/app/style.css +++ b/src/app/style.css @@ -219,7 +219,7 @@ div .string { } #loader{ - display: block; + display: none; text-align: center; width: 50%; margin: 0 auto; diff --git a/src/main.js b/src/main.js index f201249..a329e79 100644 --- a/src/main.js +++ b/src/main.js @@ -24,10 +24,11 @@ unhandled(); require('electron-context-menu')({ prepend: (params, browserWindow) => [{}] }); - +let hasCookie = false; const store = new Store(); global.abb = request.jar(); + // migrate creds from store to OS keychain const migrate = async () => { if (!!store.get('username') && (!!store.get('password'))) { @@ -199,12 +200,31 @@ const loggedOut = () => { tray.setToolTip('Login to check your usage....'); } +const checkAbbCookie = () => { + return new Promise((resolve, reject) => { + if(!hasCookie){ + resolve(false); + }else{ + resolve(true); + } + }); + +} + const updateData = async () => { loggedIn(); if (!!creds.account && !!creds.password) { - let login = await abbLogin(creds.account,creds.password); + + let cookieCheck = await checkAbbCookie(); + console.log(cookieCheck); + if(cookieCheck === false){ + let login = await abbLogin(creds.account,creds.password); + + } let service = await getCustomerData(); let result = await getUsage(service.service_id); + + console.log(service,result); let usage = {} @@ -258,7 +278,7 @@ const abbLogin = (user,pass) =>{ reject(res); } else{ - + hasCookie = true; resolve(res); } } @@ -342,6 +362,7 @@ const logOut = async () => { await deletePassword('AUNT', creds.account); creds.account = null; creds.password = null; + hasCookie = false; } catch (e) { sendMessage('asynchronous-message', 'error', 'deleting Account and Password failed') console.log(e);