mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 07:33:12 +09:00
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:
1 parent
019ffc25f0
commit
0c0626564a
9 files changed
+128
-96
No files matched your search
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user