Merge branch 'develop' of github.com:thecodingmachine/workadventure
This commit is contained in:
commit
3c1c82fbd9
16
.github/workflows/end_to_end_tests.yml
vendored
16
.github/workflows/end_to_end_tests.yml
vendored
@ -32,14 +32,14 @@ jobs:
|
||||
- name: "Wait for environment to build (and downloading testcafe image)"
|
||||
run: (docker-compose -f docker-compose.testcafe.yml pull &) && docker-compose logs -f --tail=0 front | grep -q "Compiled successfully"
|
||||
|
||||
- name: "temp debug: display logs"
|
||||
run: docker-compose logs
|
||||
|
||||
- name: "Wait for back start"
|
||||
run: docker-compose logs -f back | grep -q "WorkAdventure HTTP API starting on port"
|
||||
|
||||
- name: "Wait for pusher start"
|
||||
run: docker-compose logs -f pusher | grep -q "WorkAdventure starting on port"
|
||||
# - name: "temp debug: display logs"
|
||||
# run: docker-compose logs
|
||||
#
|
||||
# - name: "Wait for back start"
|
||||
# run: docker-compose logs -f back | grep -q "WorkAdventure HTTP API starting on port"
|
||||
#
|
||||
# - name: "Wait for pusher start"
|
||||
# run: docker-compose logs -f pusher | grep -q "WorkAdventure starting on port"
|
||||
|
||||
- name: "Run tests"
|
||||
run: docker-compose -f docker-compose.testcafe.yml up --exit-code-from testcafe
|
||||
|
@ -59,6 +59,7 @@
|
||||
"JITSI_URL": env.JITSI_URL,
|
||||
"API_URL": "back1:50051,back2:50051",
|
||||
"SECRET_JITSI_KEY": env.SECRET_JITSI_KEY,
|
||||
"FRONT_URL": "https://play-"+url
|
||||
} + (if adminUrl != null then {
|
||||
"ADMIN_API_URL": adminUrl,
|
||||
"ADMIN_API_TOKEN": env.ADMIN_API_TOKEN,
|
||||
|
@ -177,8 +177,9 @@ class ConnectionManager {
|
||||
//before set token of user we must load room and all information. For example the mandatory authentication could be require on current room
|
||||
this._currentRoom = await Room.createRoom(new URL(roomPath));
|
||||
|
||||
//defined last room url this room path
|
||||
localUserStore.setLastRoomUrl(this._currentRoom.key);
|
||||
//Set last room visited! (connected or nor, must to be saved in localstorage and cache API)
|
||||
//use href to keep # value
|
||||
localUserStore.setLastRoomUrl(this._currentRoom.href);
|
||||
|
||||
//todo: add here some kind of warning if authToken has expired.
|
||||
if (!this.authToken && !this._currentRoom.authenticationMandatory) {
|
||||
@ -189,8 +190,15 @@ class ConnectionManager {
|
||||
analyticsClient.loggedWithSso();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
this.loadOpenIDScreen();
|
||||
return Promise.reject(new Error("You will be redirect on login page"));
|
||||
//if user must to be connect in current room or pusher error is not openid provier access error
|
||||
//try to connected with function loadOpenIDScreen
|
||||
if (
|
||||
this._currentRoom.authenticationMandatory ||
|
||||
(err.response?.data && err.response.data !== "User cannot to be connected on openid provier")
|
||||
) {
|
||||
this.loadOpenIDScreen();
|
||||
return Promise.reject(new Error("You will be redirect on login page"));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.localUser = localUserStore.getLocalUser() as LocalUser; //if authToken exist in localStorage then localUser cannot be null
|
||||
|
@ -176,6 +176,10 @@ export class Room {
|
||||
return newUrl.toString();
|
||||
}
|
||||
|
||||
public get href(): string {
|
||||
return this.roomUrl.toString();
|
||||
}
|
||||
|
||||
get textures(): CharacterTexture[] | undefined {
|
||||
return this._textures;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ export class GameManager {
|
||||
return EnableCameraSceneName;
|
||||
} else {
|
||||
this.activeMenuSceneAndHelpCameraSettings();
|
||||
//TODO fix to return href with # saved in localstorage
|
||||
return this.startRoom.key;
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,8 @@ class UrlManager {
|
||||
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);
|
||||
//use href to keep # value
|
||||
localUserStore.setLastRoomUrl(room.href);
|
||||
const hash = window.location.hash;
|
||||
const search = room.search.toString();
|
||||
history.pushState({}, "WorkAdventure", room.id + (search ? "?" + search : "") + hash);
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { HtmlUtils } from "./HtmlUtils";
|
||||
import { Subject } from "rxjs";
|
||||
import { iframeListener } from "../Api/IframeListener";
|
||||
import { touchScreenManager } from "../Touch/TouchScreenManager";
|
||||
import { waScaleManager } from "../Phaser/Services/WaScaleManager";
|
||||
import { ICON_URL } from "../Enum/EnvironmentVariable";
|
||||
|
||||
@ -107,7 +106,7 @@ class CoWebsiteManager {
|
||||
this.cowebsiteBufferDom = HtmlUtils.getElementByIdOrFail<HTMLDivElement>(cowebsiteBufferDomId);
|
||||
this.cowebsiteAsideDom = HtmlUtils.getElementByIdOrFail<HTMLDivElement>(cowebsiteAsideDomId);
|
||||
this.cowebsiteSubIconsDom = HtmlUtils.getElementByIdOrFail<HTMLDivElement>(cowebsiteSubIconsDomId);
|
||||
this.initResizeListeners(touchScreenManager.supportTouchScreen);
|
||||
this.initResizeListeners();
|
||||
|
||||
this.resizeObserver.observe(this.cowebsiteDom);
|
||||
this.resizeObserver.observe(this.cowebsiteContainerDom);
|
||||
@ -176,7 +175,7 @@ class CoWebsiteManager {
|
||||
);
|
||||
}
|
||||
|
||||
private initResizeListeners(touchMode: boolean) {
|
||||
private initResizeListeners() {
|
||||
const movecallback = (event: MouseEvent | TouchEvent) => {
|
||||
let x, y;
|
||||
if (event.type === "mousemove") {
|
||||
@ -195,23 +194,32 @@ class CoWebsiteManager {
|
||||
this.fire();
|
||||
};
|
||||
|
||||
this.cowebsiteAsideDom.addEventListener(touchMode ? "touchstart" : "mousedown", (event) => {
|
||||
this.cowebsiteAsideDom.addEventListener("mousedown", (event) => {
|
||||
this.cowebsiteMainDom.style.display = "none";
|
||||
this.resizing = true;
|
||||
if (touchMode) {
|
||||
const touchEvent = (event as TouchEvent).touches[0];
|
||||
this.previousTouchMoveCoordinates = { x: touchEvent.pageX, y: touchEvent.pageY };
|
||||
}
|
||||
|
||||
document.addEventListener(touchMode ? "touchmove" : "mousemove", movecallback);
|
||||
document.addEventListener("mousemove", movecallback);
|
||||
});
|
||||
|
||||
document.addEventListener(touchMode ? "touchend" : "mouseup", (event) => {
|
||||
document.addEventListener("mouseup", (event) => {
|
||||
if (!this.resizing) return;
|
||||
if (touchMode) {
|
||||
this.previousTouchMoveCoordinates = null;
|
||||
}
|
||||
document.removeEventListener(touchMode ? "touchmove" : "mousemove", movecallback);
|
||||
document.removeEventListener("mousemove", movecallback);
|
||||
this.cowebsiteMainDom.style.display = "block";
|
||||
this.resizing = false;
|
||||
this.cowebsiteMainDom.style.display = "flex";
|
||||
});
|
||||
|
||||
this.cowebsiteAsideDom.addEventListener("touchstart", (event) => {
|
||||
this.cowebsiteMainDom.style.display = "none";
|
||||
this.resizing = true;
|
||||
const touchEvent = event.touches[0];
|
||||
this.previousTouchMoveCoordinates = { x: touchEvent.pageX, y: touchEvent.pageY };
|
||||
document.addEventListener("touchmove", movecallback);
|
||||
});
|
||||
|
||||
document.addEventListener("touchend", (event) => {
|
||||
if (!this.resizing) return;
|
||||
this.previousTouchMoveCoordinates = null;
|
||||
document.removeEventListener("touchmove", movecallback);
|
||||
this.cowebsiteMainDom.style.display = "block";
|
||||
this.resizing = false;
|
||||
this.cowebsiteMainDom.style.display = "flex";
|
||||
|
@ -5,7 +5,7 @@ import { adminApi, FetchMemberDataByUuidResponse } from "../Services/AdminApi";
|
||||
import { AuthTokenData, jwtTokenManager } from "../Services/JWTTokenManager";
|
||||
import { parse } from "query-string";
|
||||
import { openIDClient } from "../Services/OpenIDClient";
|
||||
import { DISABLE_ANONYMOUS } from "../Enum/EnvironmentVariable";
|
||||
import { DISABLE_ANONYMOUS, FRONT_URL } from "../Enum/EnvironmentVariable";
|
||||
|
||||
export interface TokenInterface {
|
||||
userUuid: string;
|
||||
@ -80,7 +80,11 @@ export class AuthenticateController extends BaseController {
|
||||
this.addCorsHeaders(res);
|
||||
return res.end(JSON.stringify({ ...resUserData, authToken: token }));
|
||||
}
|
||||
throw Error("Token cannot to be check on Hydra");
|
||||
console.error("Token cannot to be check on OpenId provider");
|
||||
res.writeStatus("500");
|
||||
res.writeHeader("Access-Control-Allow-Origin", FRONT_URL);
|
||||
res.end("User cannot to be connected on openid provier");
|
||||
return;
|
||||
}
|
||||
|
||||
const resCheckTokenAuth = await openIDClient.checkTokenAuth(authTokenData.accessToken);
|
||||
@ -93,7 +97,17 @@ export class AuthenticateController extends BaseController {
|
||||
}
|
||||
|
||||
//user have not token created, check data on hydra and create token
|
||||
const userInfo = await openIDClient.getUserInfo(code as string, nonce as string);
|
||||
let userInfo = null;
|
||||
try {
|
||||
userInfo = await openIDClient.getUserInfo(code as string, nonce as string);
|
||||
} catch (err) {
|
||||
//if no access on openid provider, return error
|
||||
console.error("User cannot to be connected on OpenId provider => ", err);
|
||||
res.writeStatus("500");
|
||||
res.writeHeader("Access-Control-Allow-Origin", FRONT_URL);
|
||||
res.end("User cannot to be connected on openid provier");
|
||||
return;
|
||||
}
|
||||
const sub = userInfo.sub;
|
||||
if (!sub) {
|
||||
throw new Error("No sub in the response");
|
||||
|
Loading…
Reference in New Issue
Block a user