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
@@ -8,6 +8,7 @@ import libConfig from "@clusterio/lib/config";
|
||||
import App from "./components/App";
|
||||
import { Control, ControlConnector } from "./util/websocket";
|
||||
|
||||
|
||||
async function loadScript(url) {
|
||||
let script = document.createElement("script");
|
||||
script.src = url;
|
||||
@@ -61,17 +62,11 @@ async function load() {
|
||||
let wsUrl = new URL(window.webRoot, document.location);
|
||||
wsUrl.protocol = wsUrl.protocol.replace("http", "ws");
|
||||
|
||||
let controlConnector = new ControlConnector(wsUrl, 10, localStorage.getItem("master_token"));
|
||||
let controlConnector = new ControlConnector(wsUrl, 10);
|
||||
// XXX come up with a better way of sharing this
|
||||
window.control = new Control(controlConnector, []);
|
||||
try {
|
||||
await controlConnector.connect();
|
||||
} catch (err) {
|
||||
// XXX: What now?
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById("root"));
|
||||
ReactDOM.render(<App control={control}/>, document.getElementById("root"));
|
||||
}
|
||||
|
||||
load().catch(console.log);
|
||||
Reference in new issue
Block a user