Change accès token with query privateAccessToken in the url

Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com>
This commit is contained in:
Gregoire Parant
2022-02-07 19:26:34 +01:00
parent 31f3b2b48e
commit 876ddc87d2
2 changed files with 58 additions and 5 deletions
+21 -2
View File
@@ -3,13 +3,16 @@ import { localUserStore } from "../Connexion/LocalUserStore";
export enum GameConnexionTypes {
room = 1,
register,
register /*@deprecated*/,
empty,
unknown,
jwt,
login,
privateAccessToken,
}
export const queryPrivateAccessToken = "privateAccessToken";
//this class is responsible with analysing and editing the game's url
class UrlManager {
public getGameConnexionType(): GameConnexionTypes {
@@ -19,8 +22,13 @@ class UrlManager {
} else if (url === "/jwt") {
return GameConnexionTypes.jwt;
} else if (url.includes("_/") || url.includes("*/") || url.includes("@/")) {
if (window.location.search.includes(queryPrivateAccessToken)) {
return GameConnexionTypes.privateAccessToken;
}
return GameConnexionTypes.room;
} else if (url.includes("register/")) {
}
//@deprecated register url will be replace by "?privateAccessToken=<private access token>"
else if (url.includes("register/")) {
return GameConnexionTypes.register;
} else if (url === "/") {
return GameConnexionTypes.empty;
@@ -29,6 +37,17 @@ class UrlManager {
}
}
/**
* @return string
*/
get getPrivateAccessToken(): string | null {
const urlParams = new URLSearchParams(window.location.search.toString());
return urlParams.get(queryPrivateAccessToken);
}
/**
* @deprecated
*/
public getOrganizationToken(): string | null {
const match = /\/register\/(.+)/.exec(window.location.pathname.toString());
return match ? match[1] : null;