diff --git a/web/src/App.js b/web/src/App.js index 85955d3b..f58058eb 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -146,16 +146,14 @@ class App extends Component { } } - getAccessTokenParam() { + getAccessTokenParam(params) { // "/page?access_token=123" - const params = new URLSearchParams(this.props.location.search); const accessToken = params.get("access_token"); return accessToken === null ? "" : `?accessToken=${accessToken}`; } - getCredentialParams() { + getCredentialParams(params) { // "/page?username=abc&password=123" - const params = new URLSearchParams(this.props.location.search); if (params.get("username") === null || params.get("password") === null) { return ""; } @@ -163,8 +161,17 @@ class App extends Component { } getUrlWithoutQuery() { - // eslint-disable-next-line no-restricted-globals - return location.toString().replace(location.search, ""); + return window.location.toString().replace(window.location.search, ""); + } + + getLanguageParam(params) { + // "/page?language=en" + const language = params.get("language"); + if (language !== null) { + Setting.setLanguage(language); + return `language=${language}`; + } + return ""; } setLanguage(account) { @@ -175,13 +182,23 @@ class App extends Component { } getAccount() { - let query = this.getAccessTokenParam(); + const params = new URLSearchParams(this.props.location.search); + + let query = this.getAccessTokenParam(params); if (query === "") { - query = this.getCredentialParams(); + query = this.getCredentialParams(params); } + + const query2 = this.getLanguageParam(params); + if (query2 !== "") { + const url = window.location.toString().replace(new RegExp(`[?&]${query2}`), ""); + window.history.replaceState({}, document.title, url); + } + if (query !== "") { window.history.replaceState({}, document.title, this.getUrlWithoutQuery()); } + AuthBackend.getAccount(query) .then((res) => { let account = null; @@ -417,20 +434,20 @@ class App extends Component { ); - // res.push( - // - // - // {i18next.t("general:Products")} - // - // - // ); - // res.push( - // - // - // {i18next.t("general:Payments")} - // - // - // ); + res.push( + + + {i18next.t("general:Products")} + + + ); + res.push( + + + {i18next.t("general:Payments")} + + + ); res.push(