d2b8d7dc04
* Active authentication Oauth - Google authentication - GitHub authentication - Linkedin authentication Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Finish connexion et get user info connexion Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Fix lint error Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Change the expires token for 30 days Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Update connexion stratgey - Set last room when it will be created and not when connexion is openned - Add '/login' end point permit to logout and open iframe to log user - Add logout feature permit to logout in front Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Implement logout and revoke token with hydra Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Fix pull develop conflict Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Profile url (#1399) * Create function that permit to get profile URL Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Continue profil user Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Add menu and logout button Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Update last room use Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Profile callback permit to get url profile setting from admin Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Finish profile show Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Delete profileUrl will be not use today Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Correct lint Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Update size of iframe Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Delete console log Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> * Update feedback ARP Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com>
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import type { Room } from "../Connexion/Room";
|
|
import { localUserStore } from "../Connexion/LocalUserStore";
|
|
|
|
export enum GameConnexionTypes {
|
|
anonymous = 1,
|
|
organization,
|
|
register,
|
|
empty,
|
|
unknown,
|
|
jwt,
|
|
login,
|
|
}
|
|
|
|
//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") {
|
|
return GameConnexionTypes.jwt;
|
|
} else if (url.includes("_/")) {
|
|
return GameConnexionTypes.anonymous;
|
|
} else if (url.includes("@/")) {
|
|
return GameConnexionTypes.organization;
|
|
} else if (url.includes("register/")) {
|
|
return GameConnexionTypes.register;
|
|
} else if (url === "/") {
|
|
return GameConnexionTypes.empty;
|
|
} else {
|
|
return GameConnexionTypes.unknown;
|
|
}
|
|
}
|
|
|
|
public getOrganizationToken(): string | null {
|
|
const match = /\/register\/(.+)/.exec(window.location.pathname.toString());
|
|
return match ? match[1] : null;
|
|
}
|
|
|
|
public pushRoomIdToUrl(room: Room): void {
|
|
if (window.location.pathname === room.id) return;
|
|
//Set last room visited! (connected or nor, must to be saved in localstorage and cache API)
|
|
localUserStore.setLastRoomUrl(room.key);
|
|
const hash = window.location.hash;
|
|
const search = room.search.toString();
|
|
history.pushState({}, "WorkAdventure", room.id + (search ? "?" + search : "") + hash);
|
|
}
|
|
|
|
public getStartLayerNameFromUrl(): string | null {
|
|
const hash = window.location.hash;
|
|
return hash.length > 1 ? hash.substring(1) : null;
|
|
}
|
|
|
|
pushStartLayerNameToUrl(startLayerName: string): void {
|
|
window.location.hash = startLayerName;
|
|
}
|
|
}
|
|
|
|
export const urlManager = new UrlManager();
|