Merge pull request #415 from thecodingmachine/hotfix/adminSocket

HOTFIX: fixed server crash on /map
This commit is contained in:
David Négrier 2020-11-13 12:18:46 +01:00 committed by GitHub
commit b888acdc15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -43,6 +43,7 @@ export class IoSocketController {
if (token !== ADMIN_API_TOKEN) { if (token !== ADMIN_API_TOKEN) {
console.log('Admin access refused for token: '+token) console.log('Admin access refused for token: '+token)
res.writeStatus("401 Unauthorized").end('Incorrect token'); res.writeStatus("401 Unauthorized").end('Incorrect token');
return;
} }
const roomId = query.roomId as string; const roomId = query.roomId as string;

View File

@ -1,11 +1,9 @@
import {OK} from "http-status-codes";
import {URL_ROOM_STARTED} from "../Enum/EnvironmentVariable";
import {HttpRequest, HttpResponse, TemplatedApp} from "uWebSockets.js"; import {HttpRequest, HttpResponse, TemplatedApp} from "uWebSockets.js";
import {BaseController} from "./BaseController"; import {BaseController} from "./BaseController";
import {parse} from "query-string"; import {parse} from "query-string";
import {adminApi} from "../Services/AdminApi"; import {adminApi} from "../Services/AdminApi";
//todo: delete this
export class MapController extends BaseController{ export class MapController extends BaseController{
constructor(private App : TemplatedApp) { constructor(private App : TemplatedApp) {
@ -36,18 +34,21 @@ export class MapController extends BaseController{
res.writeStatus("400 Bad request"); res.writeStatus("400 Bad request");
this.addCorsHeaders(res); this.addCorsHeaders(res);
res.end("Expected organizationSlug parameter"); res.end("Expected organizationSlug parameter");
return;
} }
if (typeof query.worldSlug !== 'string') { if (typeof query.worldSlug !== 'string') {
console.error('Expected worldSlug parameter'); console.error('Expected worldSlug parameter');
res.writeStatus("400 Bad request"); res.writeStatus("400 Bad request");
this.addCorsHeaders(res); this.addCorsHeaders(res);
res.end("Expected worldSlug parameter"); res.end("Expected worldSlug parameter");
return;
} }
if (typeof query.roomSlug !== 'string' && query.roomSlug !== undefined) { if (typeof query.roomSlug !== 'string' && query.roomSlug !== undefined) {
console.error('Expected only one roomSlug parameter'); console.error('Expected only one roomSlug parameter');
res.writeStatus("400 Bad request"); res.writeStatus("400 Bad request");
this.addCorsHeaders(res); this.addCorsHeaders(res);
res.end("Expected only one roomSlug parameter"); res.end("Expected only one roomSlug parameter");
return;
} }
(async () => { (async () => {