fix worlds endpoint
This commit is contained in:
@@ -109,16 +109,12 @@ export class MapController extends BaseController {
|
|||||||
res.onAborted(() => {
|
res.onAborted(() => {
|
||||||
console.warn("/message request was aborted");
|
console.warn("/message request was aborted");
|
||||||
});
|
});
|
||||||
const { userIdentify, token } = parse(req.getQuery());
|
const { token } = parse(req.getQuery());
|
||||||
try {
|
try {
|
||||||
//verify connected by token
|
//verify connected by token
|
||||||
if (token != undefined) {
|
if (token != undefined) {
|
||||||
try {
|
try {
|
||||||
const authTokenData: AuthTokenData = jwtTokenManager.verifyJWTToken(token as string, false);
|
jwtTokenManager.verifyJWTToken(token as string, false);
|
||||||
if (authTokenData.hydraAccessToken == undefined) {
|
|
||||||
throw Error("Token cannot to be check on Hydra");
|
|
||||||
}
|
|
||||||
|
|
||||||
const result: any[] = [];
|
const result: any[] = [];
|
||||||
for (const room of socketManager.getWorlds().values()) {
|
for (const room of socketManager.getWorlds().values()) {
|
||||||
const world: any = {};
|
const world: any = {};
|
||||||
@@ -135,15 +131,21 @@ export class MapController extends BaseController {
|
|||||||
result.push(world);
|
result.push(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
res.writeStatus("200 OK");
|
||||||
.writeStatus("200 OK")
|
res.writeHeader("Content-Type", "application/json");
|
||||||
.writeHeader("Content-Type", "application/json")
|
this.addCorsHeaders(res);
|
||||||
.end(
|
res.end(
|
||||||
JSON.stringify({ worlds: result })
|
JSON.stringify({ worlds: result })
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return this.errorToResponse(error, res);
|
res.writeStatus("403 FORBIDDEN");
|
||||||
|
this.addCorsHeaders(res);
|
||||||
|
res.end();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
res.writeStatus("401 UNAUTHORIZED");
|
||||||
|
this.addCorsHeaders(res);
|
||||||
|
res.end();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("getWorlds => ERROR", error);
|
console.error("getWorlds => ERROR", error);
|
||||||
|
|||||||
Reference in New Issue
Block a user