From 52f3cd1f153952a1da430e936447091a9a30cd7d Mon Sep 17 00:00:00 2001 From: Arne van Iterson Date: Sun, 10 May 2020 15:37:47 +0200 Subject: [PATCH] Removed auto-login because it was too buggy --- data/data.json | 2 +- html/main.hbs | 3 +++ main.js | 2 ++ src/auth.js | 28 ++++++++++++++-------------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/data/data.json b/data/data.json index f53c986..829c016 100644 --- a/data/data.json +++ b/data/data.json @@ -1 +1 @@ -{"theme":"dark","user":"arne.v.iterson@hotmail.nl","password":""} \ No newline at end of file +{"theme":"light","user":"arne.v.iterson@hotmail.nl","password":""} \ No newline at end of file diff --git a/html/main.hbs b/html/main.hbs index a6331b1..8cc5208 100644 --- a/html/main.hbs +++ b/html/main.hbs @@ -18,6 +18,9 @@

+

+ Logging out will delete your password from storage, if you want it to autofill next time you can just close this window when you are done. +

diff --git a/main.js b/main.js index 97b6936..ed9a72e 100644 --- a/main.js +++ b/main.js @@ -42,10 +42,12 @@ require("electron-handlebars")({ // Respond to renderer requests ipcMain.on("getAuth", (event) => { + authData = JSON.parse(fs.readFileSync("./data/data.json")); event.returnValue = authData; }); ipcMain.on("setAuth", (event, data) => { + authData = JSON.parse(fs.readFileSync("./data/data.json")); if (data != authData) { fs.writeFileSync("./data/data.json", JSON.stringify(data)); } diff --git a/src/auth.js b/src/auth.js index 825d696..bd47607 100644 --- a/src/auth.js +++ b/src/auth.js @@ -54,19 +54,19 @@ async function authenticate(user, password) { } // Get access token from Mojang Authserver -if (authData.password == "") { - // Display auth screen when no password data is found - const form = document.querySelectorAll("div.content > form")[0]; - form.querySelectorAll("input#user")[0].value = authData.user; +const form = document.querySelectorAll("div.content > form")[0]; +form.querySelectorAll("input#user")[0].value = authData.user; +form.querySelectorAll("input#password")[0].value = authData.password; + +if (authData.password != "") { + form.querySelectorAll("input#save")[0].checked = true; +} - // Listen for form submit - form.addEventListener("submit", function(e) { - e.preventDefault(); - authData.user = form.querySelectorAll("input#user")[0].value; - authData.password = form.querySelectorAll("input#password")[0].value; - save = form.querySelectorAll("input#save")[0].checked; - authenticate(authData.user, authData.password); - }); -} else { +// Listen for form submit +form.addEventListener("submit", function(e) { + e.preventDefault(); + authData.user = form.querySelectorAll("input#user")[0].value; + authData.password = form.querySelectorAll("input#password")[0].value; + save = form.querySelectorAll("input#save")[0].checked; authenticate(authData.user, authData.password); -} \ No newline at end of file +}); \ No newline at end of file