Removing the temporary error message when moving to open id screen
This commit is contained in:
@@ -45,8 +45,10 @@ class ConnectionManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO fix me to be move in game manager
|
* 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 state = localUserStore.generateState();
|
||||||
const nonce = localUserStore.generateNonce();
|
const nonce = localUserStore.generateNonce();
|
||||||
localUserStore.setAuthToken(null);
|
localUserStore.setAuthToken(null);
|
||||||
@@ -59,7 +61,6 @@ class ConnectionManager {
|
|||||||
redirectUrl.searchParams.append("state", state);
|
redirectUrl.searchParams.append("state", state);
|
||||||
redirectUrl.searchParams.append("nonce", nonce);
|
redirectUrl.searchParams.append("nonce", nonce);
|
||||||
redirectUrl.searchParams.append("playUri", this._currentRoom.key);
|
redirectUrl.searchParams.append("playUri", this._currentRoom.key);
|
||||||
window.location.assign(redirectUrl.toString());
|
|
||||||
return redirectUrl;
|
return redirectUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +84,10 @@ class ConnectionManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to login to the node server and return the starting map url to be loaded
|
* 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();
|
const connexionType = urlManager.getGameConnexionType();
|
||||||
this.connexionType = connexionType;
|
this.connexionType = connexionType;
|
||||||
this._currentRoom = null;
|
this._currentRoom = null;
|
||||||
@@ -101,8 +104,9 @@ class ConnectionManager {
|
|||||||
|
|
||||||
if (connexionType === GameConnexionTypes.login) {
|
if (connexionType === GameConnexionTypes.login) {
|
||||||
this._currentRoom = await Room.createRoom(new URL(localUserStore.getLastRoomUrl()));
|
this._currentRoom = await Room.createRoom(new URL(localUserStore.getLastRoomUrl()));
|
||||||
if (this.loadOpenIDScreen() !== null) {
|
const redirect = this.loadOpenIDScreen();
|
||||||
return Promise.reject(new Error("You will be redirect on login page"));
|
if (redirect !== null) {
|
||||||
|
return redirect;
|
||||||
}
|
}
|
||||||
urlManager.pushRoomIdToUrl(this._currentRoom);
|
urlManager.pushRoomIdToUrl(this._currentRoom);
|
||||||
} else if (connexionType === GameConnexionTypes.jwt) {
|
} else if (connexionType === GameConnexionTypes.jwt) {
|
||||||
@@ -124,8 +128,11 @@ class ConnectionManager {
|
|||||||
analyticsClient.loggedWithSso();
|
analyticsClient.loggedWithSso();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
this.loadOpenIDScreen();
|
const redirect = this.loadOpenIDScreen();
|
||||||
return Promise.reject(new Error("You will be redirect on login page"));
|
if (redirect === null) {
|
||||||
|
throw new Error("Unable to redirect on login page.");
|
||||||
|
}
|
||||||
|
return redirect;
|
||||||
}
|
}
|
||||||
urlManager.pushRoomIdToUrl(this._currentRoom);
|
urlManager.pushRoomIdToUrl(this._currentRoom);
|
||||||
} else if (connexionType === GameConnexionTypes.register) {
|
} else if (connexionType === GameConnexionTypes.register) {
|
||||||
@@ -212,8 +219,11 @@ class ConnectionManager {
|
|||||||
err.response?.data &&
|
err.response?.data &&
|
||||||
err.response.data !== "User cannot to be connected on openid provider")
|
err.response.data !== "User cannot to be connected on openid provider")
|
||||||
) {
|
) {
|
||||||
this.loadOpenIDScreen();
|
const redirect = this.loadOpenIDScreen();
|
||||||
return Promise.reject(new Error("You will be redirect on login page"));
|
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 { LoginSceneName } from "../Login/LoginScene";
|
||||||
import { SelectCharacterSceneName } from "../Login/SelectCharacterScene";
|
import { SelectCharacterSceneName } from "../Login/SelectCharacterScene";
|
||||||
import { GameScene } from "./GameScene";
|
import { GameScene } from "./GameScene";
|
||||||
|
import { EmptySceneName } from "../Login/EmptyScene";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class should be responsible for any scene starting/stopping
|
* 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> {
|
public async init(scenePlugin: Phaser.Scenes.ScenePlugin): Promise<string> {
|
||||||
this.scenePlugin = scenePlugin;
|
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);
|
this.loadMap(this.startRoom);
|
||||||
|
|
||||||
//If player name was not set show login scene with player name
|
//If player name was not set show login scene with player name
|
||||||
|
|||||||
@@ -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 &&
|
||||||
gameManager.currentStartedRoom.authenticationMandatory
|
gameManager.currentStartedRoom.authenticationMandatory
|
||||||
) {
|
) {
|
||||||
connectionManager.loadOpenIDScreen();
|
const redirect = connectionManager.loadOpenIDScreen();
|
||||||
|
if (redirect !== null) {
|
||||||
|
window.location.assign(redirect.toString());
|
||||||
|
}
|
||||||
loginSceneVisibleIframeStore.set(true);
|
loginSceneVisibleIframeStore.set(true);
|
||||||
}
|
}
|
||||||
loginSceneVisibleStore.set(true);
|
loginSceneVisibleStore.set(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user