Clean token auth of url params

Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com>
This commit is contained in:
Gregoire Parant 2021-11-24 15:49:45 +01:00
parent be3c1eea6f
commit b02c09fc7b

View file

@ -84,7 +84,8 @@ class ConnectionManager {
if (token) { if (token) {
this.authToken = token; this.authToken = token;
localUserStore.setAuthToken(token); localUserStore.setAuthToken(token);
//token was saved, clear url
//clean token of url
urlParams.delete("token"); urlParams.delete("token");
} }
@ -95,8 +96,6 @@ class ConnectionManager {
} }
urlManager.pushRoomIdToUrl(this._currentRoom); urlManager.pushRoomIdToUrl(this._currentRoom);
} else if (connexionType === GameConnexionTypes.jwt) { } else if (connexionType === GameConnexionTypes.jwt) {
const urlParams = new URLSearchParams(window.location.search);
if (!token) { if (!token) {
const code = urlParams.get("code"); const code = urlParams.get("code");
const state = urlParams.get("state"); const state = urlParams.get("state");
@ -139,7 +138,7 @@ class ConnectionManager {
"//" + "//" +
window.location.host + window.location.host +
roomUrl + roomUrl +
window.location.search + urlParams.toString() + //use urlParams because the token param must be deleted
window.location.hash window.location.hash
) )
); );
@ -169,7 +168,7 @@ class ConnectionManager {
"//" + "//" +
window.location.host + window.location.host +
window.location.pathname + window.location.pathname +
window.location.search + urlParams.toString() + //use urlParams because the token param must be deleted
window.location.hash; window.location.hash;
} }
@ -218,8 +217,6 @@ class ConnectionManager {
analyticsClient.identifyUser(this.localUser.uuid, this.localUser.email); analyticsClient.identifyUser(this.localUser.uuid, this.localUser.email);
} }
//clean history with new URL
window.history.pushState({}, document.title, window.location.pathname);
this.serviceWorker = new _ServiceWorker(); this.serviceWorker = new _ServiceWorker();
return Promise.resolve(this._currentRoom); return Promise.resolve(this._currentRoom);
} }