add login mechanic

This commit is contained in:
2024-01-11 01:00:43 +01:00
parent 6790fe5ef6
commit 05b9ddd5a1
7 changed files with 138 additions and 67 deletions

20
main.js
View File

@@ -16,9 +16,23 @@ function isDev() {
}
function registerIPCPipes() {
ipcMain.handle("ezpplauncher:login", (e, args) => {
console.log(args);
return "yes";
ipcMain.handle("ezpplauncher:login", async (e, args) => {
const fetchResult = await fetch("https://ez-pp.farm/login/check", {
method: "POST",
body: JSON.stringify({ username: args.username, password: args.password }),
headers: {
"Content-Type": "application/json",
},
});
if (fetchResult.ok) {
const result = await fetchResult.json();
if (result.code == 200) return result;
}
return {
code: 403,
message: "Invalid username or password.",
}
});
}