- if (this.state.user.id > 0)
- {
- ajax("/whoami", "GET", res => {
- this.state.user.email = res.email;
- this.state.user.notify = res.notify;
- });
- // TODO: fetch is simpler, but does not set req.xhr (for security check)
-// fetch(params.serverUrl + "/whoami", {
-// method: "GET",
-// credentials: params.cors ? "include" : "omit",
-// }).then((res) => {
-// return res.json()
-// }).then((user) => {
-// this.state.user.email = user.email;
-// this.state.user.notify = user.notify;
-// });
- }
- this.state.conn = new WebSocket(params.socketUrl + "/?sid=" + mysid);
+ // Slow verification through the server:
+ // NOTE: still superficial identity usurpation possible, but difficult.
+ ajax("/whoami", "GET", res => {
+ this.state.user.id = res.id;
+ this.state.user.name = res.name;
+ this.state.user.email = res.email;
+ this.state.user.notify = res.notify;
+ });
+ const supportedLangs = ["en","es","fr"];
+ this.state.lang = localStorage["lang"] ||
+ (supportedLangs.includes(navigator.language)
+ ? navigator.language
+ : "en");
+ this.setTranslations();
+ // Initialize connection (even if the current page doesn't need it)
+ this.state.conn = new WebSocket(params.socketUrl + "/?sid=" + mysid +
+ "&page=" + encodeURIComponent(page));