Refactor access by token

Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com>
This commit is contained in:
Gregoire Parant
2022-03-19 07:11:15 +01:00
parent 56fb73c682
commit 29a0b9c5ae
2 changed files with 6 additions and 54 deletions
+5 -17
View File
@@ -6,28 +6,24 @@ export enum GameConnexionTypes {
register /*@deprecated*/,
empty,
unknown,
jwt,
jwt /*@deprecated*/,
login,
privateAccessToken,
}
export const queryPrivateAccessToken = "privateAccessToken";
//this class is responsible with analysing and editing the game's url
class UrlManager {
public getGameConnexionType(): GameConnexionTypes {
const url = window.location.pathname.toString();
if (url === "/login") {
return GameConnexionTypes.login;
} else if (url === "/jwt") {
}
//@deprecated jwt url will be replace by "?token=<private access token>"
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;
}
//@deprecated register url will be replace by "?privateAccessToken=<private access token>"
//@deprecated register url will be replace by "?token=<private access token>"
else if (url.includes("register/")) {
return GameConnexionTypes.register;
} else if (url === "/") {
@@ -37,14 +33,6 @@ class UrlManager {
}
}
/**
* @return string
*/
get privateAccessToken(): string | null {
const urlParams = new URLSearchParams(window.location.search.toString());
return urlParams.get(queryPrivateAccessToken);
}
/**
* @deprecated
*/