Finishing steam login.

This commit is contained in:
Tristan Roux
2019-04-05 23:01:17 +02:00
parent 500b3f0387
commit 41811409f8
5 changed files with 79 additions and 41 deletions
+1 -1
View File
@@ -8,6 +8,6 @@
}
],
"settings": {
"liveServer.settings.multiRootWorkspaceName": "EAU-Backend"
"liveServer.settings.multiRootWorkspaceName": "EAU"
}
}
+2 -2
View File
File diff suppressed because one or more lines are too long
+54 -31
View File
@@ -1,9 +1,51 @@
const { app, BrowserWindow, protocol } = require('electron')
const LocalGameDiscovery = require("./src/js/LocalGameSearch");
const { app, BrowserWindow } = require('electron')
// const LocalGameDiscovery = require("./src/js/LocalGameSearch");
const Store = require("./src/js/store");
const log = require("electron-log");
var win;
const lock = app.requestSingleInstanceLock();
if (!lock)
app.quit();
else
{
app.on("second-instance", (_event, argv) =>
{
log.log("handling new arg (from second instance)");
handleArgs(argv.slice(1).toString());
if (win)
{
if (win.isMinimized())
win.restore();
win.focus();
}
});
app.setAsDefaultProtocolClient("eau");
app.on("ready", () =>
{
createWindow();
handleArgs(process.argv.slice(1).toString());
});
app.on("window-all-closed", () =>
{
if (process.platform !== "darwin")
app.quit()
});
app.on("activate", () =>
{
if (win === null)
createWindow();
});
// console.log(typeof LocalGameDiscovery.init);
// LocalGameDiscovery.init();
}
function createWindow()
{
win = new BrowserWindow({ width: 1080, height: 720 });
@@ -16,33 +58,14 @@ function createWindow()
});
}
app.setAsDefaultProtocolClient("eau");
app.on("ready", () =>
function handleArgs(arg)
{
createWindow();
protocol.registerHttpProtocol("eau", (request, callback) =>
log.log("arg: " + arg);
if (arg.startsWith("eau://steam-"))
{
console.log(request.url);
console.log("callback: " + callback.name);
}, (error) =>
{
console.log(error);
});
});
app.on("window-all-closed", () =>
{
if (process.platform !== "darwin")
app.quit()
});
app.on("activate", () =>
{
if (win === null)
createWindow();
});
console.log(typeof LocalGameDiscovery.init);
LocalGameDiscovery.init();
var token = arg.substring(arg.lastIndexOf("id/") + 3);
log.log("Token: " + token);
var store = new Store("account");
store.set("steam", token);
}
}
+5 -5
View File
@@ -1,12 +1,12 @@
require("elecron");
require("path");
require("fs");
const electron = require("electron");
const path = require("path");
const fs = require("fs");
class Store
{
constructor(name)
{
this.path = path.join((Electron.app || Electron.remote.app).getPath("userData"), name + ".json");
this.path = path.join((electron.app || electron.remote.app).getPath("userData"), name + ".json");
this.data = readFile(this.path);
}
@@ -30,7 +30,7 @@ function readFile(path)
}
catch
{
return null;
return {};
}
}
+17 -2
View File
@@ -32,12 +32,27 @@ enum launcher
Steam
}
export function populateGrid()
{
var steamToken;
var userAgent = navigator.userAgent.toLowerCase();
if (userAgent.indexOf(" electron/") > -1)
{
const Store = require("../js/store");
const store = new Store("account");
steamToken = store.get("steam");
console.log("steamToken: " + steamToken);
}
else
{
console.log("AGENT IS NOT ELECTRON, NO HANDLING FOR NOW");
steamToken = "76561198250223174"; //A default steam client id (for testing only)
}
$.get("https://api.steampowered.com/IPlayerService/GetOwnedGames/v1/" +
"?key=7C218E8D1347C3CD6CB8117E5ED533BC" +
"&steamid=76561198250223174" +
"&steamid=" + steamToken +
"&include_appinfo=1" +
"&include_played_free_games=1" +
"&appids_filter=", (data) =>