Removing the temporary error message when moving to open id screen
This commit is contained in:
parent
e20a8caa26
commit
f1549a0ee0
@ -45,8 +45,10 @@ class ConnectionManager {
|
||||
|
||||
/**
|
||||
* TODO fix me to be move in game manager
|
||||
*
|
||||
* Returns the URL that we need to redirect to to load the OpenID screen, or "null" if no redirection needs to happen.
|
||||
*/
|
||||
public loadOpenIDScreen() {
|
||||
public loadOpenIDScreen(): URL | null {
|
||||
const state = localUserStore.generateState();
|
||||
const nonce = localUserStore.generateNonce();
|
||||
localUserStore.setAuthToken(null);
|
||||
@ -59,7 +61,6 @@ class ConnectionManager {
|
||||
redirectUrl.searchParams.append("state", state);
|
||||
redirectUrl.searchParams.append("nonce", nonce);
|
||||
redirectUrl.searchParams.append("playUri", this._currentRoom.key);
|
||||
window.location.assign(redirectUrl.toString());
|
||||
return redirectUrl;
|
||||
}
|
||||
|
||||
@ -83,8 +84,10 @@ class ConnectionManager {
|
||||
|
||||
/**
|
||||
* Tries to login to the node server and return the starting map url to be loaded
|
||||
*
|
||||
* @return returns a promise to the Room we are going to load OR a pointer to the URL we must redirect to if authentication is needed.
|
||||
*/
|
||||
public async initGameConnexion(): Promise<Room> {
|
||||
public async initGameConnexion(): Promise<Room | URL> {
|
||||
const connexionType = urlManager.getGameConnexionType();
|
||||
this.connexionType = connexionType;
|
||||
this._currentRoom = null;
|
||||
@ -101,8 +104,9 @@ class ConnectionManager {
|
||||
|
||||
if (connexionType === GameConnexionTypes.login) {
|
||||
this._currentRoom = await Room.createRoom(new URL(localUserStore.getLastRoomUrl()));
|
||||
if (this.loadOpenIDScreen() !== null) {
|
||||
return Promise.reject(new Error("You will be redirect on login page"));
|
||||
const redirect = this.loadOpenIDScreen();
|
||||
if (redirect !== null) {
|
||||
return redirect;
|
||||
}
|
||||
urlManager.pushRoomIdToUrl(this._currentRoom);
|
||||
} else if (connexionType === GameConnexionTypes.jwt) {
|
||||
@ -124,8 +128,11 @@ class ConnectionManager {
|
||||
analyticsClient.loggedWithSso();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
this.loadOpenIDScreen();
|
||||
return Promise.reject(new Error("You will be redirect on login page"));
|
||||
const redirect = this.loadOpenIDScreen();
|
||||
if (redirect === null) {
|
||||
throw new Error("Unable to redirect on login page.");
|
||||
}
|
||||
return redirect;
|
||||
}
|
||||
urlManager.pushRoomIdToUrl(this._currentRoom);
|
||||
} else if (connexionType === GameConnexionTypes.register) {
|
||||
@ -212,8 +219,11 @@ class ConnectionManager {
|
||||
err.response?.data &&
|
||||
err.response.data !== "User cannot to be connected on openid provider")
|
||||
) {
|
||||
this.loadOpenIDScreen();
|
||||
return Promise.reject(new Error("You will be redirect on login page"));
|
||||
const redirect = this.loadOpenIDScreen();
|
||||
if (redirect === null) {
|
||||
throw new Error("Unable to redirect on login page.");
|
||||
}
|
||||
return redirect;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import { EnableCameraSceneName } from "../Login/EnableCameraScene";
|
||||
import { LoginSceneName } from "../Login/LoginScene";
|
||||
import { SelectCharacterSceneName } from "../Login/SelectCharacterScene";
|
||||
import { GameScene } from "./GameScene";
|
||||
import { EmptySceneName } from "../Login/EmptyScene";
|
||||
|
||||
/**
|
||||
* This class should be responsible for any scene starting/stopping
|
||||
@ -32,7 +33,14 @@ export class GameManager {
|
||||
|
||||
public async init(scenePlugin: Phaser.Scenes.ScenePlugin): Promise<string> {
|
||||
this.scenePlugin = scenePlugin;
|
||||
this.startRoom = await connectionManager.initGameConnexion();
|
||||
const result = await connectionManager.initGameConnexion();
|
||||
if (result instanceof URL) {
|
||||
window.location.assign(result.toString());
|
||||
// window.location.assign is not immediate and Javascript keeps running after.
|
||||
// so we need to redirect to an empty Phaser scene, waiting for the redirection to take place
|
||||
return EmptySceneName;
|
||||
}
|
||||
this.startRoom = result;
|
||||
this.loadMap(this.startRoom);
|
||||
|
||||
//If player name was not set show login scene with player name
|
||||
|
17
front/src/Phaser/Login/EmptyScene.ts
Normal file
17
front/src/Phaser/Login/EmptyScene.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { Scene } from "phaser";
|
||||
|
||||
export const EmptySceneName = "EmptyScene";
|
||||
|
||||
export class EmptyScene extends Scene {
|
||||
constructor() {
|
||||
super({
|
||||
key: EmptySceneName,
|
||||
});
|
||||
}
|
||||
|
||||
preload() {}
|
||||
|
||||
create() {}
|
||||
|
||||
update(time: number, delta: number): void {}
|
||||
}
|
@ -28,7 +28,10 @@ export class LoginScene extends ResizableScene {
|
||||
gameManager.currentStartedRoom &&
|
||||
gameManager.currentStartedRoom.authenticationMandatory
|
||||
) {
|
||||
connectionManager.loadOpenIDScreen();
|
||||
const redirect = connectionManager.loadOpenIDScreen();
|
||||
if (redirect !== null) {
|
||||
window.location.assign(redirect.toString());
|
||||
}
|
||||
loginSceneVisibleIframeStore.set(true);
|
||||
}
|
||||
loginSceneVisibleStore.set(true);
|
||||
|
Loading…
Reference in New Issue
Block a user