Refactor connexion manager
Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com>
This commit is contained in:
parent
29a0b9c5ae
commit
e618dc6c3d
@ -85,8 +85,7 @@ 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
|
||||||
*/
|
*/
|
||||||
public async initGameConnexion(): Promise<Room> {
|
public async initGameConnexion(): Promise<Room> {
|
||||||
const connexionType = urlManager.getGameConnexionType();
|
this.connexionType = urlManager.getGameConnexionType();
|
||||||
this.connexionType = connexionType;
|
|
||||||
this._currentRoom = null;
|
this._currentRoom = null;
|
||||||
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
@ -99,13 +98,14 @@ class ConnectionManager {
|
|||||||
urlParams.delete("token");
|
urlParams.delete("token");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connexionType === GameConnexionTypes.login) {
|
if (this.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) {
|
if (this.loadOpenIDScreen() !== null) {
|
||||||
return Promise.reject(new Error("You will be redirect on login page"));
|
return Promise.reject(new Error("You will be redirect on login page"));
|
||||||
}
|
}
|
||||||
urlManager.pushRoomIdToUrl(this._currentRoom);
|
urlManager.pushRoomIdToUrl(this._currentRoom);
|
||||||
} else if (connexionType === GameConnexionTypes.jwt) {
|
} else if (this.connexionType === GameConnexionTypes.jwt) {
|
||||||
|
/** @deprecated */
|
||||||
if (!token) {
|
if (!token) {
|
||||||
const code = urlParams.get("code");
|
const code = urlParams.get("code");
|
||||||
const state = urlParams.get("state");
|
const state = urlParams.get("state");
|
||||||
@ -130,7 +130,7 @@ class ConnectionManager {
|
|||||||
urlManager.pushRoomIdToUrl(this._currentRoom);
|
urlManager.pushRoomIdToUrl(this._currentRoom);
|
||||||
}
|
}
|
||||||
//@deprecated
|
//@deprecated
|
||||||
else if (connexionType === GameConnexionTypes.register) {
|
else if (this.connexionType === GameConnexionTypes.register) {
|
||||||
const organizationMemberToken = urlManager.getOrganizationToken();
|
const organizationMemberToken = urlManager.getOrganizationToken();
|
||||||
const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken }).then(
|
const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken }).then(
|
||||||
(res) => res.data
|
(res) => res.data
|
||||||
@ -159,11 +159,11 @@ class ConnectionManager {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
urlManager.pushRoomIdToUrl(this._currentRoom);
|
urlManager.pushRoomIdToUrl(this._currentRoom);
|
||||||
} else if (connexionType === GameConnexionTypes.room || connexionType === GameConnexionTypes.empty) {
|
} else if (this.connexionType === GameConnexionTypes.room || this.connexionType === GameConnexionTypes.empty) {
|
||||||
this.authToken = localUserStore.getAuthToken();
|
this.authToken = localUserStore.getAuthToken();
|
||||||
|
|
||||||
let roomPath: string;
|
let roomPath: string;
|
||||||
if (connexionType === GameConnexionTypes.empty) {
|
if (this.connexionType === GameConnexionTypes.empty) {
|
||||||
roomPath = localUserStore.getLastRoomUrl();
|
roomPath = localUserStore.getLastRoomUrl();
|
||||||
//get last room path from cache api
|
//get last room path from cache api
|
||||||
try {
|
try {
|
||||||
|
@ -13,14 +13,14 @@ export class OpenIdProfileController extends BaseHttpController {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const resCheckTokenAuth = await openIDClient.checkTokenAuth(accessToken as string);
|
const resCheckTokenAuth = await openIDClient.checkTokenAuth(accessToken as string);
|
||||||
if (!resCheckTokenAuth.email) {
|
if (!resCheckTokenAuth.sub) {
|
||||||
throw new Error("Email was not found");
|
throw new Error("Email was not found");
|
||||||
}
|
}
|
||||||
res.send(
|
res.send(
|
||||||
this.buildHtml(
|
this.buildHtml(
|
||||||
OPID_CLIENT_ISSUER,
|
OPID_CLIENT_ISSUER,
|
||||||
resCheckTokenAuth.email as string,
|
resCheckTokenAuth.sub as string
|
||||||
resCheckTokenAuth.picture as string | undefined
|
/*resCheckTokenAuth.picture as string | undefined*/
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user