Merge branch 'develop' of github.com:thecodingmachine/workadventure into protobuf
# Conflicts: # back/package.json
This commit is contained in:
commit
cd083a2090
@ -36,6 +36,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/thecodingmachine/workadventure#readme",
|
"homepage": "https://github.com/thecodingmachine/workadventure#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"axios": "^0.20.0",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"generic-type-guard": "^3.2.0",
|
"generic-type-guard": "^3.2.0",
|
||||||
|
@ -7,6 +7,7 @@ import bodyParser = require('body-parser');
|
|||||||
import * as http from "http";
|
import * as http from "http";
|
||||||
import {MapController} from "./Controller/MapController";
|
import {MapController} from "./Controller/MapController";
|
||||||
import {PrometheusController} from "./Controller/PrometheusController";
|
import {PrometheusController} from "./Controller/PrometheusController";
|
||||||
|
import {AdminController} from "./Controller/AdminController";
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
public app: Application;
|
public app: Application;
|
||||||
@ -15,6 +16,7 @@ class App {
|
|||||||
public authenticateController: AuthenticateController;
|
public authenticateController: AuthenticateController;
|
||||||
public mapController: MapController;
|
public mapController: MapController;
|
||||||
public prometheusController: PrometheusController;
|
public prometheusController: PrometheusController;
|
||||||
|
private adminController: AdminController;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.app = express();
|
this.app = express();
|
||||||
@ -32,6 +34,7 @@ class App {
|
|||||||
this.authenticateController = new AuthenticateController(this.app);
|
this.authenticateController = new AuthenticateController(this.app);
|
||||||
this.mapController = new MapController(this.app);
|
this.mapController = new MapController(this.app);
|
||||||
this.prometheusController = new PrometheusController(this.app, this.ioSocketController);
|
this.prometheusController = new PrometheusController(this.app, this.ioSocketController);
|
||||||
|
this.adminController = new AdminController(this.app);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO add session user
|
// TODO add session user
|
||||||
|
36
back/src/Controller/AdminController.ts
Normal file
36
back/src/Controller/AdminController.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import {Application, Request, Response} from "express";
|
||||||
|
import {OK} from "http-status-codes";
|
||||||
|
import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable";
|
||||||
|
import Axios from "axios";
|
||||||
|
|
||||||
|
export class AdminController {
|
||||||
|
App : Application;
|
||||||
|
|
||||||
|
constructor(App : Application) {
|
||||||
|
this.App = App;
|
||||||
|
this.getLoginUrlByToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getLoginUrlByToken(){
|
||||||
|
this.App.get("/register/:token", async (req: Request, res: Response) => {
|
||||||
|
if (!ADMIN_API_URL) {
|
||||||
|
return res.status(500).send('No admin backoffice set!');
|
||||||
|
}
|
||||||
|
const token:string = req.params.token;
|
||||||
|
|
||||||
|
let response = null
|
||||||
|
try {
|
||||||
|
response = await Axios.get(ADMIN_API_URL+'/api/login-url/'+token, { headers: {"Authorization" : `${ADMIN_API_TOKEN}`} })
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e.message)
|
||||||
|
return res.status(e.status || 500).send('An error happened');
|
||||||
|
}
|
||||||
|
|
||||||
|
const organizationSlug = response.data.organizationSlug;
|
||||||
|
const worldSlug = response.data.worldSlug;
|
||||||
|
const roomSlug = response.data.roomSlug;
|
||||||
|
return res.status(OK).send({organizationSlug, worldSlug, roomSlug});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -3,11 +3,15 @@ const URL_ROOM_STARTED = "/Floor0/floor0.json";
|
|||||||
const MINIMUM_DISTANCE = process.env.MINIMUM_DISTANCE ? Number(process.env.MINIMUM_DISTANCE) : 64;
|
const MINIMUM_DISTANCE = process.env.MINIMUM_DISTANCE ? Number(process.env.MINIMUM_DISTANCE) : 64;
|
||||||
const GROUP_RADIUS = process.env.GROUP_RADIUS ? Number(process.env.GROUP_RADIUS) : 48;
|
const GROUP_RADIUS = process.env.GROUP_RADIUS ? Number(process.env.GROUP_RADIUS) : 48;
|
||||||
const ALLOW_ARTILLERY = process.env.ALLOW_ARTILLERY ? process.env.ALLOW_ARTILLERY == 'true' : false;
|
const ALLOW_ARTILLERY = process.env.ALLOW_ARTILLERY ? process.env.ALLOW_ARTILLERY == 'true' : false;
|
||||||
|
const ADMIN_API_URL = process.env.ADMIN_API_URL || null;
|
||||||
|
const ADMIN_API_TOKEN = process.env.ADMIN_API_TOKEN || null;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
SECRET_KEY,
|
SECRET_KEY,
|
||||||
URL_ROOM_STARTED,
|
URL_ROOM_STARTED,
|
||||||
MINIMUM_DISTANCE,
|
MINIMUM_DISTANCE,
|
||||||
|
ADMIN_API_URL,
|
||||||
|
ADMIN_API_TOKEN,
|
||||||
GROUP_RADIUS,
|
GROUP_RADIUS,
|
||||||
ALLOW_ARTILLERY
|
ALLOW_ARTILLERY,
|
||||||
}
|
}
|
@ -249,6 +249,13 @@ async-limiter@~1.0.0:
|
|||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd"
|
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd"
|
||||||
|
|
||||||
|
axios@^0.20.0:
|
||||||
|
version "0.20.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/axios/-/axios-0.20.0.tgz#057ba30f04884694993a8cd07fa394cff11c50bd"
|
||||||
|
integrity sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==
|
||||||
|
dependencies:
|
||||||
|
follow-redirects "^1.10.0"
|
||||||
|
|
||||||
backo2@1.0.2:
|
backo2@1.0.2:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947"
|
resolved "https://registry.yarnpkg.com/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947"
|
||||||
@ -779,6 +786,11 @@ flatted@^2.0.0:
|
|||||||
version "2.0.2"
|
version "2.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
|
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
|
||||||
|
|
||||||
|
follow-redirects@^1.10.0:
|
||||||
|
version "1.13.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.0.tgz#b42e8d93a2a7eea5ed88633676d6597bc8e384db"
|
||||||
|
integrity sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==
|
||||||
|
|
||||||
forwarded@~0.1.2:
|
forwarded@~0.1.2:
|
||||||
version "0.1.2"
|
version "0.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84"
|
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84"
|
||||||
|
@ -10,10 +10,12 @@ import {FourOFourScene} from "./Phaser/Reconnecting/FourOFourScene";
|
|||||||
import WebGLRenderer = Phaser.Renderer.WebGL.WebGLRenderer;
|
import WebGLRenderer = Phaser.Renderer.WebGL.WebGLRenderer;
|
||||||
import {OutlinePipeline} from "./Phaser/Shaders/OutlinePipeline";
|
import {OutlinePipeline} from "./Phaser/Shaders/OutlinePipeline";
|
||||||
import {CustomizeScene} from "./Phaser/Login/CustomizeScene";
|
import {CustomizeScene} from "./Phaser/Login/CustomizeScene";
|
||||||
import {HtmlUtils} from "./WebRtc/HtmlUtils";
|
|
||||||
import {CoWebsiteManager} from "./WebRtc/CoWebsiteManager";
|
import {CoWebsiteManager} from "./WebRtc/CoWebsiteManager";
|
||||||
|
import {redirectIfToken} from "./register";
|
||||||
|
|
||||||
//CoWebsiteManager.loadCoWebsite('https://thecodingmachine.com');
|
//CoWebsiteManager.loadCoWebsite('https://thecodingmachine.com');
|
||||||
|
let connectionData //todo: do something with this data
|
||||||
|
redirectIfToken().then(res => connectionData = res);
|
||||||
|
|
||||||
// Load Jitsi if the environment variable is set.
|
// Load Jitsi if the environment variable is set.
|
||||||
if (JITSI_URL) {
|
if (JITSI_URL) {
|
||||||
|
29
front/src/register.ts
Normal file
29
front/src/register.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import Axios from "axios";
|
||||||
|
import {API_URL} from "./Enum/EnvironmentVariable";
|
||||||
|
declare let history:History;
|
||||||
|
|
||||||
|
//todo: better naming
|
||||||
|
export interface ConnexionData {
|
||||||
|
organizationSlug: string,
|
||||||
|
worldSlug: string,
|
||||||
|
roomSlug: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function redirectIfToken(): Promise<ConnexionData | null> {
|
||||||
|
const match = /\/register\/(.+)/.exec(window.location.toString());
|
||||||
|
if (!match) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
let res = null;
|
||||||
|
try {
|
||||||
|
res = await Axios.get(`${API_URL}/register/`+match[1])
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const organizationSlug = res.data.organizationSlug;
|
||||||
|
const worldSlug = res.data.worldSlug;
|
||||||
|
const roomSlug = res.data.roomSlug;
|
||||||
|
const connexionUrl = '/@/'+organizationSlug+'/'+worldSlug+'/'+roomSlug;
|
||||||
|
history.pushState({}, '', connexionUrl);
|
||||||
|
return {organizationSlug, worldSlug, roomSlug};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user