Add login flow

Present user with a login form to input token when connection fails or
the token is not present in local storage.  Replaces the settings page.
This commit is contained in:
Hornwitser committed 2020-10-29 19:11:10 +01:00
1 parent 019ffc25f0
commit 0c0626564a
9 files changed
+128 -96

No files matched your search

+10 -5
View File
@@ -1,6 +1,7 @@
const libLink = require("@clusterio/lib/link");
const libPlugin = require("@clusterio/lib/plugin");
const libErrors = require("@clusterio/lib/errors");
const version = require("../../package.json").version;
/**
* Format a parsed Factorio output message
@@ -36,17 +37,21 @@ function formatOutput(output) {
* @private
*/
export class ControlConnector extends libLink.WebSocketClientConnector {
constructor(url, reconnectDelay, token) {
constructor(url, reconnectDelay) {
super(url, reconnectDelay);
this._token = token;
this.token = null;
}
register() {
if (!this.token) {
throw new Error("Token not set");
}
console.log("SOCKET | registering control");
this.sendHandshake("register_control", {
token: this._token,
agent: "web",
version: "2.0.0-alpha",
token: this.token,
agent: "Clusterio Web UI",
version,
});
}
}