workadventure/front/src/Phaser/Login/LoginScene.ts
grégoire parant 908b78fdda
HotFix mandatory login with ADMIN openid connexion (#1503)
Before anonymous connexion, we must get the details of the map and permit to check mandatory connexion and redirect user to login page.

Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com>
2021-10-05 18:59:26 +02:00

50 lines
1.5 KiB
TypeScript

import { SelectCharacterSceneName } from "./SelectCharacterScene";
import { ResizableScene } from "./ResizableScene";
import { loginSceneVisibleIframeStore, loginSceneVisibleStore } from "../../Stores/LoginSceneStore";
import { localUserStore } from "../../Connexion/LocalUserStore";
import { connectionManager } from "../../Connexion/ConnectionManager";
import { gameManager } from "../Game/GameManager";
export const LoginSceneName = "LoginScene";
export class LoginScene extends ResizableScene {
private name: string = "";
constructor() {
super({
key: LoginSceneName,
});
this.name = gameManager.getPlayerName() || "";
}
preload() {}
create() {
loginSceneVisibleIframeStore.set(false);
//If authentication is mandatory, push authentication iframe
if (
localUserStore.getAuthToken() == undefined &&
gameManager.currentStartedRoom &&
gameManager.currentStartedRoom.authenticationMandatory
) {
connectionManager.loadOpenIDScreen();
loginSceneVisibleIframeStore.set(true);
}
loginSceneVisibleStore.set(true);
}
public login(name: string): void {
name = name.trim();
gameManager.setPlayerName(name);
this.scene.stop(LoginSceneName);
gameManager.tryResumingGame(SelectCharacterSceneName);
this.scene.remove(LoginSceneName);
loginSceneVisibleStore.set(false);
}
update(time: number, delta: number): void {}
public onResize(): void {}
}