Removed auto-login because it was too buggy

This commit is contained in:
Arne van Iterson 2020-05-10 15:37:47 +02:00
parent eca50edb93
commit 52f3cd1f15
4 changed files with 20 additions and 15 deletions

View File

@ -1 +1 @@
{"theme":"dark","user":"arne.v.iterson@hotmail.nl","password":""} {"theme":"light","user":"arne.v.iterson@hotmail.nl","password":""}

View File

@ -18,6 +18,9 @@
<button id="upload">Upload Skin</button><br> <button id="upload">Upload Skin</button><br>
<button id="random">Random Skin</button><br> <button id="random">Random Skin</button><br>
<button id="logout">Logout</button> <button id="logout">Logout</button>
<p class="message info">
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.
</p>
</div> </div>
<script src="../src/main.js"></script> <script src="../src/main.js"></script>

View File

@ -42,10 +42,12 @@ require("electron-handlebars")({
// Respond to renderer requests // Respond to renderer requests
ipcMain.on("getAuth", (event) => { ipcMain.on("getAuth", (event) => {
authData = JSON.parse(fs.readFileSync("./data/data.json"));
event.returnValue = authData; event.returnValue = authData;
}); });
ipcMain.on("setAuth", (event, data) => { ipcMain.on("setAuth", (event, data) => {
authData = JSON.parse(fs.readFileSync("./data/data.json"));
if (data != authData) { if (data != authData) {
fs.writeFileSync("./data/data.json", JSON.stringify(data)); fs.writeFileSync("./data/data.json", JSON.stringify(data));
} }

View File

@ -54,19 +54,19 @@ async function authenticate(user, password) {
} }
// Get access token from Mojang Authserver // Get access token from Mojang Authserver
if (authData.password == "") { const form = document.querySelectorAll("div.content > form")[0];
// Display auth screen when no password data is found form.querySelectorAll("input#user")[0].value = authData.user;
const form = document.querySelectorAll("div.content > form")[0]; form.querySelectorAll("input#password")[0].value = authData.password;
form.querySelectorAll("input#user")[0].value = authData.user;
// Listen for form submit if (authData.password != "") {
form.addEventListener("submit", function(e) { form.querySelectorAll("input#save")[0].checked = true;
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 {
authenticate(authData.user, authData.password);
} }
// 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);
});